Template Tango Docs 1.x Help

Include, embed

You can include and embed other files. The file locations are relative to the working directory.

include just includes a file and by default passes all variables to the include (you can override that behavior, see the example).

embed basically does the same, but allows to override blocks in the embedded file with alternative content.

main.twig:

{% set name = 'Foo' %} {% include 'some_include.twig' with {name: name} only %} {% embed 'some_embed.twig' %} {% block message %}Hello {{ name }}{% endblock %} {% endembed %}

some_include.twig:

Hello {{ name }} from include!

some_embed.twig:

Some text line. {% block message %} Default message {% endblock %} Another text line
Last modified: 02 januari 2024