use
¶
The Twital instruction for Twig use
tag is t:use
node.
This is a fature that allows a/the horizontal reuse of templates. To learn more about it, you can read the official documentation.
Let’s see how does it work:
<t:use from="bars.html"/>
<t:block name="sidebar">
...
</t:block>
You can create some aliases for block inside “used” template to avoid name conflicting:
<t:extends from="layout.html.twig">
<t:use from="bars.html" aliases="sidebar as sidebar_original, footer as old_footer"/>
<t:block name="sidebar">
{{ block('sidebar_original') }}
</t:block>
</t:extends>
Note
For more information about the use
tag, please refer to
Twig official documentation.