Skip to content

! prefix referencing templates #8760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
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
3 changes: 3 additions & 0 deletions templating.rst
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,9 @@ template living inside the AcmeBlogBundle, for example, can be overridden
by placing a template of the same name in the ``app/Resources/AcmeBlogBundle/views/``
directory. This gives the power to override templates from any vendor bundle.

If you have overridden a template, you can use the "!" prefix to refer to the original bundle's
template. E.g. ``@!AcmeBlog/layout.html.twig``

Template Suffix
~~~~~~~~~~~~~~~

Expand Down
6 changes: 6 additions & 0 deletions templating/overriding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ from the bundle to ``app/Resources/AcmeBlogBundle/views/Blog/index.html.twig``
(the ``app/Resources/AcmeBlogBundle`` directory won't exist, so you'll need
to create it). You're now free to customize the template.

.. versionadded:: 3.4

Instead of overridding an entire template, you may just want to override one or more blocks. You can do that by extending the original
template using the "!" prefix. For example:
``{% extends "@!AcmeBlogBundle/layout.html.twig" %}``

.. caution::

If you add a template in a new location, you *may* need to clear your
Expand Down