# compose

Source: https://zotonic.com/docs/2506/compose

URI: https://zotonic.com/id/2506

Language: en



::: {.aside}
See also

<a href="/id/doc_template_tag_tag_catcompose" class="doc-reference doc-reference-tag"><code>tag#catcompose</code></a>, <a href="/id/doc_template_tag_tag_block" class="doc-reference doc-reference-tag"><code>tag#block</code></a>, <a href="/id/doc_template_tag_tag_fragment" class="doc-reference doc-reference-tag"><code>tag#fragment</code></a> and <a href="/id/doc_template_tag_tag_useblock" class="doc-reference doc-reference-tag"><code>tag#useblock</code></a>.
:::

Compose another template and override its named blocks.

The `compose` tag renders another template, like <a href="/id/doc_template_tag_tag_include" class="doc-reference doc-reference-tag"><code>tag#include</code></a>, but also lets the caller define <a href="/id/doc_template_tag_tag_block" class="doc-reference doc-reference-tag"><code>tag#block</code></a> overrides for the composed template.

Example:

```django
{% compose "_panel.tpl" title="Summary" %}
    {% block body %}
        <p>Hello world</p>
    {% endblock %}
{% endcompose %}
```

The composed template can define blocks such as `body`, and the `compose` caller can override those blocks.

Arguments
---------

Like the <a href="/id/doc_template_tag_tag_include" class="doc-reference doc-reference-tag"><code>tag#include</code></a> tag, the `with` keyword is optional:

```django
{% compose "_panel.tpl" title="Summary" %}
    {% block body %}Hello{% endblock %}
{% endcompose %}

{% compose "_panel.tpl" with title="Summary" %}
    {% block body %}Hello{% endblock %}
{% endcompose %}
```

The supplied arguments extend the current template context for the composed template render.

::: {.note title="Note"}
The template name can be an expression. If it is not a string literal then the template is selected at runtime.
:::

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/2506?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/2506?language=en>)
