Skip to content

Tag Formatters¤

Tag formatters allow you to change the syntax for calling components from within the Django templates.

Tag formatter are set via the tag_formatter setting.

Available tag formatters¤

ComponentFormatter ¤

Bases: django_components.tag_formatter.TagFormatterABC

See source code

The original django_component's component tag formatter, it uses the {% component %} and {% endcomponent %} tags, and the component name is given as the first positional arg.

Example as block:

{% component "mycomp" abc=123 %}
    {% fill "myfill" %}
        ...
    {% endfill %}
{% endcomponent %}

Example as inlined tag:

{% component "mycomp" abc=123 / %}

ShorthandComponentFormatter ¤

Bases: django_components.tag_formatter.TagFormatterABC

See source code

The component tag formatter that uses {% <name> %} / {% end<name> %} tags.

This is similar to django-web-components and django-slippers syntax.

Example as block:

{% mycomp abc=123 %}
    {% fill "myfill" %}
        ...
    {% endfill %}
{% endmycomp %}

Example as inlined tag:

{% mycomp abc=123 / %}