Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #2245 added support for a custom template on the block() func…
…tion (fabpot) This PR was merged into the 1.x branch. Discussion ---------- added support for a custom template on the block() function `block()` allows one to render a block of the current template. This PR adds the possibility to use `block()` to render a block of another template: ```twig {{ block('footer', template_name) }} ``` As it uses the same logic as for the regular `block()`, you can also use it in a test: ```twig {% if block('footer', template_name) is defined %} ... {% endif %} ``` This removes the needs to use the internal `Twig_Template::renderBlock()` method in the Symfony Web Profiler for instance. And combined with #2236, it allows us to really mark the whole `Twig_Template` class as being internal. I'm aware that #1302 asked for being able to pass a context to `block()` (implemented in #1433), but I prefer not to in favor of adding the `with` tag (see #719 and #1054). When the `with` will be implemented, the code in the Symfony Web Profiler will become something along the lines of: ```twig {% with { 'collector': profile.getcollector(name), 'profiler_url': profiler_url, 'token': profile.token, 'name': name } %} {{ block('toolbar', template) }} {% endwith %} ``` Commits ------- 5ed59be added support for a custom template on the block() function
- Loading branch information
Showing
5 changed files
with
55 additions
and
13 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
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
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
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
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