fragment

See also

use, useblock, block, extends and overrules.

Define a named reusable template fragment.

A fragment is a named piece of template output that can be reused with the use and useblock tags.

Fragments can also contain template block definitions. Those blocks can be addressed from a useblock call, similar to compose.

Example:

{% fragment answer_row %}
    <div class="row">
        <label>{{ label }}</label>
        <span>{{ value }}</span>
    </div>
{% endfragment %}

{% use answer_row label="Email" value=user.email %}
{% use answer_row with label="Phone" value=user.phone %}

The fragment definition itself does not render any output at the place where it is defined.

Fragments are available in the template where they are defined, and in templates that extend or overrule that template.

Fragments use the current template context. Extra variables can be supplied by the use or useblock tags.