File tree Expand file tree Collapse file tree 2 files changed +18
-7
lines changed
Filter options
Expand file tree Collapse file tree 2 files changed +18
-7
lines changed
Original file line number Diff line number Diff line change @@ -365,9 +365,6 @@ template living inside the AcmeBlogBundle, for example, can be overridden
365
365
by placing a template of the same name in the ``app/Resources/AcmeBlogBundle/views/ ``
366
366
directory. This gives the power to override templates from any vendor bundle.
367
367
368
- If you have overridden a template, you can use the "!" prefix to refer to the original bundle's
369
- template. E.g. ``@!AcmeBlog/layout.html.twig ``
370
-
371
368
Template Suffix
372
369
~~~~~~~~~~~~~~~
373
370
Original file line number Diff line number Diff line change @@ -19,11 +19,25 @@ from the bundle to ``app/Resources/AcmeBlogBundle/views/Blog/index.html.twig``
19
19
(the ``app/Resources/AcmeBlogBundle `` directory won't exist, so you'll need
20
20
to create it). You're now free to customize the template.
21
21
22
+ Instead of overriding an entire template, you may just want to override one or
23
+ more blocks. However, since you are overriding the template you want to extend
24
+ from, you would end up in an infinite loop error. The solution is to use the
25
+ special ``! `` prefix in the template name to tell Symfony that you want to
26
+ extend from the original template, not from the overridden one:
27
+
28
+ .. code-block :: twig
29
+
30
+ {# app/Resources/AcmeBlogBundle/views/Blog/index.html.twig #}
31
+
32
+ {# the special '!' prefix avoids errors when extending from an overridden template #}
33
+ {% extends "@!AcmeBlogBundle/index.html.twig" %}
34
+
35
+ {% block some_block %}
36
+ ...
37
+ {% endblock %}
38
+
22
39
.. versionadded :: 3.4
23
-
24
- Instead of overridding an entire template, you may just want to override one or more blocks. You can do that by extending the original
25
- template using the "!" prefix. For example:
26
- ``{% extends "@!AcmeBlogBundle/layout.html.twig" %} ``
40
+ The special ``! `` template prefix was introduced in Symfony 3.4.
27
41
28
42
.. caution ::
29
43
You can’t perform that action at this time.
0 commit comments