草庐IT

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

coder 2024-04-11 原文

是否可以从宏中访问当前模板的变量而不直接将变量传递给宏?谢谢。

最佳答案

可以将所有上下文变量传递给宏:

{{ macro(_context) }}

_contextspecial variable ,其中包含所有当前定义的变量(按名称 => 值)。

关于PHP Twig : access current template variable from within macro without passing?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7586924/

有关PHP Twig : access current template variable from within macro without passing?的更多相关文章

随机推荐