Is it possible to retrieve all variables inside a Twig template with PHP?
Example someTemplate.twig.php:
Hello {{ name }},
your new email is {{ email }}
Now I want to do something like this:
$template = $twig->loadTemplate('someTemplate');
$variables = $template->…
Currently I place my function in a class and pass an instance of this class into template and call my required function as a class method.
{{ unneededclass.blah() }}
I need to do like below
{{ blah() }}
Is it possible?
Why Twig documentation recommends to use extending rather than including? Symfony 2 documentation says because "In Symfony2, we like to think about this problem differently: a template can be decorated by another one." but nothing more. It's just author's whim or …