What's Changed
Perf
Rendering components is now ~20% faster, thanks to:
- using Rust-based template tag parsing
- skipping eager input validation in favour of on-exception handling
Feat
-
BaseNodeclass now has thefiltersandtagsattributes. These dictionaries keep track of what filters and tags can be used within the{% %}tag.Extensions can use these attributes to add custom filters and tags to the tag.
Refactor
-
In template, when a component tag has a positional argument
after a keyword argument it now raisesSyntaxErrorinstead ofTypeError.{% mytag 'John' msg='Hello' 123 %}
-
When a component tag receives multiple kwargs with the same name, it no longer raises
TypeError.Instead, the later kwargs overwrite the earlier ones.
{% mytag 'John' x=123 x=456 %}
-
All template tags (
{% component %},{% slot %}, etc.) now include the exact tag (as found in the template) in the error message when an error occurs:TypeError: Error in mytag: missing 1 required keyword-only arguments: 'msg' 1 | {% mytag 'John' %} ^^^^^^^^^^^^^^^^^^
-
When creating custom template tags with
BaseNodeclass or@template_tagdecorator, you now get an error when
the tag name is the same as one of the flags:class SlotNode(BaseNode): tag = "slot" allowed_flags = ["slot"] # Raises!
Full Changelog: 0.144.0...0.145.0