I'm using a standalone Twig instance in a custom application, but parameters (context) passed to the template seem to be surprisingly ignored.
Executing the following code results in this error :
Fatal error: Uncaught exception 'Twig_Error_Runtime' with message 'Variable " msg" does not exist in "hello.twig" (...)
test.php
$options = array(
'charset' => 'utf-8',
'debug' => true,
'strict_variables' => true,
);
$env = new Twig_Environment(new \Twig_Loader_Filesystem(getcwd()), $options);
return $env->render("hello.twig", array('msg' => 'World'));
// I also tried this
return $env->loadTemplate("hello.twig")->render(array('msg' => 'World'));
hello.twig
Hello {{ msg }}
Registering a global variable ( $env->addGlobal('msg', 'Everybody') ) is no more successful.
Did I miss something or should it be working?