Skip to content

Fix macros imported in the body of a for loop not being available after it - #5010

Open
nicolas-grekas wants to merge 1 commit into
twigphp:4.xfrom
nicolas-grekas:for-loop-macro-imports
Open

nicolas-grekas wants to merge 1 commit into
twigphp:4.xfrom
nicolas-grekas:for-loop-macro-imports

Conversation

@nicolas-grekas

Copy link
Copy Markdown
Contributor

Since 4.x compiles the body of a for loop in a closure, the macros imported in the body were only available inside the loop. Using them after the loop threw an error saying that the template body wasn't rendered, while this works on 3.x. The closure now uses the macros of the enclosing scope by reference.

@@ -0,0 +1,16 @@
--TEST--
"for" tag keeps the macros imported in its body available after the loop

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this test be added in 3.x as well ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in #5011; I split the fixture so that the 3.x one merges up as is, the recursive case being 4.x only

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants