gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:03:47 25 4
gpt4 key购买 nike

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

最佳答案

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

{{ macro(_context) }}

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

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com