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

家住魔仙堡 提交于 2019-12-10 16:45:51

问题


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


回答1:


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).



来源:https://stackoverflow.com/questions/7586924/php-twig-access-current-template-variable-from-within-macro-without-passing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!