简体   繁体   中英

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM