Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Twig: access current template variable from within macro without passing?

Tags:

php

twig

silex

Is it possible to access the current template's variables from within a macro without passing the variable to the macro directly? Thanks.

like image 484
user635028 Avatar asked Dec 27 '22 13:12

user635028


1 Answers

It's possible to pass all context variables to a macro:

{{ macro(_context) }}

_context is a special variable, which contains all currently defined variables (by name => value).

like image 128
NikiC Avatar answered Jan 17 '23 15:01

NikiC