Theme
Version
GitHubPyPIDiscord
On this page

Tag formatters

A TagFormatter controls the start/end tag names a component is rendered with. django-components ships these predefined formatters.

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 / %}
django-components version: 0.152.0