v0.125ยค
โ ๏ธ Attention โ ๏ธ - We migrated from EmilStenstrom/django-components
to django-components/django-components
.
Repo name and documentation URL changed. Package name remains the same.
If you see any broken links or other issues, please report them in #922.
Featยค
@template_tag
andBaseNode
- A decorator and a class that allow you to define custom template tags that will behave similarly to django-components' own template tags.
Read more on Template tags.
Template tags defined with @template_tag
and BaseNode
will have the following features:
-
Accepting args, kwargs, and flags.
-
Allowing literal lists and dicts as inputs as:
key=[1, 2, 3]
orkey={"a": 1, "b": 2}
- Using template tags tag inputs as:{% my_tag key="{% lorem 3 w %}" / %}
- Supporting the flat dictionary definition:attr:key=value
- Spreading args and kwargs with...
:{% my_tag ...args ...kwargs / %}
- Being able to call the template tag as:{% my_tag %} ... {% endmy_tag %}
or{% my_tag / %}
Refactorยค
-
Refactored template tag input validation. When you now call template tags like
{% slot %}
,{% fill %}
,{% html_attrs %}
, and others, their inputs are now validated the same way as Python function inputs are.So, for example
will raise an error, because the positional argument
name
is given twice.NOTE: Special kwargs whose keys are not valid Python variable names are not affected by this change. So when you define:
The
data-id
will still be accepted as a valid kwarg, assuming that yourget_context_data()
accepts**kwargs
: