Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tests/Fixtures/tags/for/import_in_body.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--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

--TEMPLATE--
{% macro hello(name) %}Hello {{ name }}{% endmacro %}
{% for name in ['Fabien'] %}{% import _self as macros %}{{ macros.hello(name) }}, {% endfor %}
{{ macros.hello('Twig') }}
{% for name in ['Nicolas'] %}{% import _self as indexed %}{{ indexed.hello(name ~ loop.index) }}, {% endfor %}
{{ indexed.hello('Twig') }}
--DATA--
return []
--EXPECT--
Hello Fabien, Hello Twig
Hello Nicolas1, Hello Twig
10 changes: 10 additions & 0 deletions tests/Fixtures/tags/for/import_in_recursive_body.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--TEST--
"for" tag keeps the macros imported in the body of a recursive loop available after the loop
--TEMPLATE--
{% macro hello(name) %}Hello {{ name }}{% endmacro %}
{% for name in ['Fabien'] %}{% import _self as recursive %}{{ recursive.hello(name) }}, {% if false %}{{ loop([]) }}{% endif %}{% endfor %}
{{ recursive.hello('Twig') }}
--DATA--
return []
--EXPECT--
Hello Fabien, Hello Twig
Loading