F
F
fedorenko_k2016-08-09 22:36:23
Facebook
fedorenko_k, 2016-08-09 22:36:23

twig template engine?

Hello, why does the Twig templating engine output the template name and not its content?

require_once 'vendor/autoload.php';
 Twig_Autoloader::register();

 $view = $_SESSION['view'];
 $loader = new Twig_Loader_String("templates/$view");
 $twig = new Twig_Environment($loader, array(
    'cache'       => 'templates/_GlobalCache',
    'auto_reload' => true
 ));

 echo $twig->render('index.php', array(
  'user' => $_SESSION['ref']
 ));

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Philip Khlopunov, 2016-04-27
@dimmanthall

Try this option here.
www.masterskayafanstranic.com.ua/kak-izmenit-nazva...

M
Maxim, 2016-08-10
@pudovMaxim

Because Twig_Loader_String takes a string as a template. NOT the NAME of the template, but the contents of the template. Those. for Twig_Loader_String to work, you need to do something like this
UPD: You should probably use something like this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question