src/TwigEnv.php
public function renderPath($filePath='', $tplData=[], $return=true, $isPage=false)
    {
        // Remove the start of the templates path, since Twig asks
        // for a path starting from one of the registered directories.
        $path = $this->normalizePath($filePath);
        $prefix = $this->templateDir . '/';
        if (strpos($path, $prefix) === 0) {
            $path = substr($path, strlen($prefix));
        }

        try {
            $content = $this->twig->render($path, $tplData);
        }
        catch (Twig_Error $err) {
            $content = $this->error($err, $isPage);
        }

        // Mimicking the API of Tpl::load and how it's called by
        // Kirby\Component\Template::render.
        if ($return) return $content;
        echo $content;
    }
public function renderPath($filePath='', $tplData=[], $return=true, $isPage=false)
    {
        // Remove the start of the templates path, since Twig asks
        // for a path starting from one of the registered directories.
        $path = $this->normalizePath($filePath);
        $prefix = $this->templateDir . '/';
        if (strpos($path, $prefix) === 0) {
            $path = substr($path, strlen($prefix));
        }

        try {
            $content = $this->twig->render($path, $tplData);
        }
        catch (Twig_Error $err) {
            $content = $this->error($err, $isPage);
        }

        // Mimicking the API of Tpl::load and how it's called by
        // Kirby\Component\Template::render.
        if ($return) return $content;
        echo $content;
    }
public function renderPath ( $ filePath = '' , $ tplData = [ ] , $ return = true , $ isPage = false ) { // Remove the start of the templates path, since Twig asks // for a path starting from one of the registered directories. $ path = $ this -> normalizePath ( $ filePath ) ; $ prefix = $ this -> templateDir . '/' ; if ( strpos ( $ path , $ prefix ) === 0 ) { $ path = substr ( $ path , strlen ( $ prefix ) ) ; } try { $ content = $ this -> twig -> render ( $ path , $ tplData ) ; } catch ( Twig_Error $ err ) { $ content = $ this -> error ( $ err , $ isPage ) ; } // Mimicking the API of Tpl::load and how it's called by // Kirby\Component\Template::render. if ( $ return ) return $ content ; echo $ content ; }
Render a Twig template from a file path,
similarly to how Tpl::load renders a PHP template
@param string $filePath
@param array $tplData
@param bool $return
@param bool $isPage
@return string
@throws Twig_Error
Render a Twig template from a file path similarly to how Tpl :: load renders a PHP template