# catcompose

Source: https://zotonic.com/docs/2508/catcompose

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

Language: en



::: {.aside}
See also

<a href="/id/doc_template_tag_tag_compose" class="doc-reference doc-reference-tag"><code>tag#compose</code></a>, <a href="/id/doc_template_tag_tag_catinclude" class="doc-reference doc-reference-tag"><code>tag#catinclude</code></a> and <a href="/id/doc_template_tag_tag_block" class="doc-reference doc-reference-tag"><code>tag#block</code></a>.
:::

Compose another template based on the category of a resource.

The `catcompose` tag is the category-aware variant of <a href="/id/doc_template_tag_tag_compose" class="doc-reference doc-reference-tag"><code>tag#compose</code></a>. It selects the template using category lookup, like <a href="/id/doc_template_tag_tag_catinclude" class="doc-reference doc-reference-tag"><code>tag#catinclude</code></a>, and also lets the caller override named blocks in the selected template.

Example:

```django
{% catcompose "_teaser.tpl" id %}
    {% block body %}
        <p>Custom teaser body</p>
    {% endblock %}
{% endcompose %}
```

The selected template depends on the category hierarchy of `id`, using the same lookup rules as <a href="/id/doc_template_tag_tag_catinclude" class="doc-reference doc-reference-tag"><code>tag#catinclude</code></a>.

Arguments
---------

Extra arguments can be passed to the composed template:

```django
{% catcompose "_teaser.tpl" id title="Summary" %}
    {% block body %}Custom teaser body{% endblock %}
{% endcompose %}
```

The `with` keyword is optional here as well:

```django
{% catcompose "_teaser.tpl" id with title="Summary" %}
    {% block body %}Custom teaser body{% endblock %}
{% endcompose %}
```

The resource id is also available in the composed template as `id`.

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/2508?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/2508?language=en>)
