Latte\Runtime\Template::capture PHP Method

capture() public method

Captures output to string.
public capture ( callable $function ) : string
$function callable
return string
    public function capture(callable $function)
    {
        ob_start(function () {
        });
        try {
            $this->global->coreCaptured = TRUE;
            $function();
        } catch (\Throwable $e) {
        } catch (\Exception $e) {
        }
        $this->global->coreCaptured = FALSE;
        if (isset($e)) {
            ob_end_clean();
            throw $e;
        }
        return ob_get_clean();
    }