Macro default value as variable #4483
-
In the MacroTokenParser, there is a check that default value are constants Twig/src/TokenParser/MacroTokenParser.php Line 96 in ef3dbab Which means that
is not doable. Is it something which could change or should it stay like this for some reasons/limitations ? In my linter, I want to easily identify params of a macro, can I rely on the fact this is all the Token::NAME (except macro and the macro name) between |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
This should stay like that. Supporting variables in default values would require defining in which scope they are resolved. Note that PHP also enforces constant expressions in default values. |
Beta Was this translation helpful? Give feedback.
-
Note that a default value being a mapping could have name tokens for the array keys. So assuming that all name tokens are used for argument names is probably not a shortcut you can take. |
Beta Was this translation helpful? Give feedback.
This should stay like that. Supporting variables in default values would require defining in which scope they are resolved.
Note that PHP also enforces constant expressions in default values.