You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to call macro via attribute function, where macro name will be variable, like this:
{% set var=test %}
{{ attribute(_self,var,[]) }}
{% macro test() %}
asd
{% endmacro %}
But, at this, when I call attribute funcrion, I got error message:
[24-Oct-2022 00:36:58 Europe/Berlin] PHP Fatal error: Uncaught Twig\Error\RuntimeError: Variable "test" does not exist. in /var/www/twig/templates/complexExtends/fullCoreConfiguration.twig:1
Stack trace:
#0 /var/www/twig/Twig/Environment.php(358) : eval()'d code(37): __TwigTemplate_91f65122729c67177b64bf63e9863a6c13ea15d037fb9fb61487aed7083f1fef->{closure}() #1 /var/www/twig/Twig/Template.php(394): __TwigTemplate_91f65122729c67177b64bf63e9863a6c13ea15d037fb9fb61487aed7083f1fef->doDisplay(Array, Array) #2 /var/www/twig/Twig/Template.php(367): Twig\Template->displayWithErrorHandling(Array, Array) #3 /var/www/twig/Twig/Template.php(379): Twig\Template->display(Array) #4 /var/www/twig/Twig/TemplateWrapper.php(40): Twig\Template->render(Array, Array) #5 /var/ho in /var/www/twig/templates/complexExtends/fullCoreConfiguration.twig on line 1
Case, where I call macro via attribute and macro name is constant/string, works fine:
{{ attribute(_self,'test',[]) }}
{% macro test() %}
asd
{% endmacro %}
Is there way, how can I call variable macro?
Like as my first case?
This discussion was converted from issue #3765 on December 26, 2022 16:39.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I would like to call macro via attribute function, where macro name will be variable, like this:
{% set var=test %}
{{ attribute(_self,var,[]) }}
{% macro test() %}
asd
{% endmacro %}
But, at this, when I call attribute funcrion, I got error message:
[24-Oct-2022 00:36:58 Europe/Berlin] PHP Fatal error: Uncaught Twig\Error\RuntimeError: Variable "test" does not exist. in /var/www/twig/templates/complexExtends/fullCoreConfiguration.twig:1
Stack trace:
#0 /var/www/twig/Twig/Environment.php(358) : eval()'d code(37): __TwigTemplate_91f65122729c67177b64bf63e9863a6c13ea15d037fb9fb61487aed7083f1fef->{closure}()
#1 /var/www/twig/Twig/Template.php(394): __TwigTemplate_91f65122729c67177b64bf63e9863a6c13ea15d037fb9fb61487aed7083f1fef->doDisplay(Array, Array)
#2 /var/www/twig/Twig/Template.php(367): Twig\Template->displayWithErrorHandling(Array, Array)
#3 /var/www/twig/Twig/Template.php(379): Twig\Template->display(Array)
#4 /var/www/twig/Twig/TemplateWrapper.php(40): Twig\Template->render(Array, Array)
#5 /var/ho in /var/www/twig/templates/complexExtends/fullCoreConfiguration.twig on line 1
Case, where I call macro via attribute and macro name is constant/string, works fine:
{{ attribute(_self,'test',[]) }}
{% macro test() %}
asd
{% endmacro %}
Is there way, how can I call variable macro?
Like as my first case?
Beta Was this translation helpful? Give feedback.
All reactions