-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #2269 Bugfix: When rendering blocks of other templates, don't pas…
…s the local blocks array (derrabus, fabpot) This PR was merged into the 1.x branch. Discussion ---------- Bugfix: When rendering blocks of other templates, don't pass the local blocks array This PR fixes symfony/symfony#20556. When referring to a block of another template from within a template that also has a block with the same name, Twig renders the wrong block. Commits ------- 8c090a7 added tests for block() when using a template argument a5526f3 fixed block() is defined call when using a template argument c04d077 Bugfix: When rendering blocks of other templates, don't pass the local blocks array.
- Loading branch information
Showing
4 changed files
with
74 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
* 1.28.1 (2016-XX-XX) | ||
|
||
* n/a | ||
* fixed block() function when used with a template argument | ||
|
||
* 1.28.0 (2016-11-17) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
test/Twig/Tests/Fixtures/functions/block_with_template.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--TEST-- | ||
"block" function with a template argument | ||
--TEMPLATE-- | ||
{{ block('foo', 'included.twig') }} | ||
{{ block('foo', included_loaded) }} | ||
{{ block('foo', included_loaded_internal) }} | ||
{% set output = block('foo', 'included.twig') %} | ||
{{ output }} | ||
{% block foo %}NOT FOO{% endblock %} | ||
--TEMPLATE(included.twig)-- | ||
{% block foo %}FOO{% endblock %} | ||
--DATA-- | ||
return array( | ||
'included_loaded' => $twig->load('included.twig'), | ||
'included_loaded_internal' => $twig->loadTemplate('included.twig'), | ||
) | ||
--EXPECT-- | ||
FOO | ||
FOO | ||
FOO | ||
FOO | ||
NOT FOO |
17 changes: 17 additions & 0 deletions
17
test/Twig/Tests/Fixtures/tests/defined_for_blocks_with_template.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--TEST-- | ||
"defined" support for blocks with a template argument | ||
--TEMPLATE-- | ||
{{ block('foo', 'included.twig') is defined ? 'ok' : 'ko' }} | ||
{{ block('foo', included_loaded) is defined ? 'ok' : 'ko' }} | ||
{{ block('foo', included_loaded_internal) is defined ? 'ok' : 'ko' }} | ||
--TEMPLATE(included.twig)-- | ||
{% block foo %}FOO{% endblock %} | ||
--DATA-- | ||
return array( | ||
'included_loaded' => $twig->load('included.twig'), | ||
'included_loaded_internal' => $twig->loadTemplate('included.twig'), | ||
) | ||
--EXPECT-- | ||
ok | ||
ok | ||
ok |