blockΒΆ

The Twital instruction for Twig block tag is t:block node.

To see how to use it, consider the following base template named layout.html.twital:

<html>
    <head>
        <title>Hello world!</title>
    </head>
    <body t:block="content">
        Hello!
    </div>
</html>

To improve the greeting message, we can extend it using the t:textends node, so we can create a new template called hello.html.twital.

<t:extends from="layout.html.twital">
    <t:block name="content">
        Hello {{name}}!
    </t:block>
</t:extends>

As you can see, we have overwritten the content of the content block with a new one. To do this, we have used a t:block node.

Of course, if needed, you can also call the parent block from inside. It is simple:

<t:extends from="layout.html.twital">
    <t:block name="content">
        {{parent()}}
        Hello {{name}}!
    </t:block>
</t:extends>

Note

To learn more about template inheritance, you can read the Twig official documentation