I decided to familiarize myself with the twig template engine.

require_once 'Twig/Autoloader.php'; Twig_Autoloader::register(); $loader = new Twig_Loader_Filesystem('templates/'); $view = new Twig_Environment($loader, array('cache' => '/files/cache', 'debug' => true)); 

There are no errors. Render template.

 $view->render('index.php', array('name' => 'twig')); 

In the template, only {{name}} , but when I launch it is a blank screen. Ctrl + U in the browser is empty. What could be the problem?

PS In the case of $loader = new Twig_Loader_String() string is rendered and there are no problems.

  • 2
    try return $ view-> render (...)? - MasterAlex
  • @MasterAlex return works, but the effect is 0. - sargss
  • @MasterAlex I should be more careful reading the documentation, I somehow missed echo, but thanks for pushing my mistake. - sargss
  • one
    @sargss, well, yes it only works in classes, when you need to return something, in your case, do it in the documentation: echo $ view-> render ('index.html', array ('name' => 'twig') ) // twig.sensiolabs.org/doc/api.html - MasterAlex
  • @MasterAlex yes, that's what I did, thanks - sargss

0