library ¤
Module for interfacing with Django's Library (django.template.library)
Classes:
-
TagProtectedError–The way the
TagFormatterworks is that,
Attributes:
-
PROTECTED_TAGS–These are the names that users cannot choose for their components,
PROTECTED_TAGS module-attribute ¤
PROTECTED_TAGS = ['component_css_dependencies', 'component_js_dependencies', 'fill', 'html_attrs', 'provide', 'slot']
These are the names that users cannot choose for their components, as they would conflict with other tags in the Library.
TagProtectedError ¤
Bases: Exception
The way the TagFormatter works is that, based on which start and end tags are used for rendering components, the ComponentRegistry behind the scenes un-/registers the template tags with the associated instance of Django's Library.
In other words, if I have registered a component "table", and I use the shorthand syntax:
Then ComponentRegistry registers the tag table onto the Django's Library instance.
However, that means that if we registered a component "slot", then we would overwrite the {% slot %} tag from django_components.
Thus, this exception is raised when a component is attempted to be registered under a forbidden name, such that it would overwrite one of django_component's own template tags.