dj_angles.tags
==============
.. py:module:: dj_angles.tags
Module Contents
---------------
.. py:data:: SHADOW_ATTRIBUTE_KEY
:value: 'shadow'
.. py:data:: DEFAULT_ATTRIBUTE_KEY
:value: 'default'
.. py:data:: ERROR_BOUNDARY_ATTRIBUTE_KEY
:value: 'error-boundary'
.. py:data:: ERROR_BOUNDARY_TAG_NAMES
:value: ['block']
.. py:class:: Tag(tag_map: dj_angles.mappers.mapper.TagMap | dict | None = None, html: str = '', tag_name: str = '', template_tag_args: str = '', tag_queue: Optional[collections.deque] = None)
Encapsulates metadata and functionality for a tag that will be processed by `dj-angles`.
.. py:attribute:: tag_name
:type: str
The portion of the tag's element name after the initial identifier (which defaults to 'dj-').
.. rubric:: Examples
- 'include' for ''
- 'partial' for ''
.. py:attribute:: html
:type: str
The original HTML of the tag.
.. py:attribute:: attributes
:type: dj_angles.attributes.Attributes
The parsed attributes of the template tag.
.. py:attribute:: is_shadow
:type: bool
:value: False
Whether or not the tag should use the Shadow DOM.
.. py:attribute:: is_wrapped
:type: bool
:value: True
Whether or not the tag is wrapped.
.. py:attribute:: is_end
:type: bool
:value: False
Whether or not the tag is an end tag, i.e. starts with ''.
.. py:attribute:: is_self_closing
:type: bool
:value: False
Whether or not the tag is self-closing, i.e. ends with '/>'.
.. py:attribute:: start_tag
:type: Optional[Tag]
:value: None
The associated start tag. Only set for end tags.
.. py:attribute:: outer_html
:type: str | None
:value: None
The outer HTML of the tag.
.. py:attribute:: is_error_boundary
:type: bool
:value: False
Whether or not the tag should handle errors.
.. py:attribute:: error_fallback
:type: str | None
:value: ''
What to display if there is an error. Can be a string or a template.
.. py:attribute:: inner_html
:type: str | None
:value: None
.. py:attribute:: django_template_tag
.. py:method:: parse_attributes()
Creates `Attributes` based on the template tag arguments.
.. py:method:: get_error_html(exception: Exception) -> str
Get HTML for the tag when there is an error.
.. py:method:: get_django_template_tag(slots: list[tuple[str, minestrone.Element]] | None = None) -> str
Generate the Django template tag.
:param param slots: List of slots which is a tuple of slot name and inner html.
.. py:method:: get_wrapping_tag_name(name: str | None = None) -> str
Get the wrapping tag name.
:param param name: The name for the wrapping tag.
.. py:method:: pop_attribute_value_or_first_key(attribute_name: str) -> str
Gets the first attribute key or the first value for a particular attribute name.
As a side effect of this function, if the attribute is found, it will be removed from
`tag.attributes` because almost always that is the desired behavior. `tag.parse_attributes()`
can be called for the `tag` if needed for future needs, i.e. when in an end tag and needing
the attributes for a start tag.
:param param attribute_name: The name of the attribute to get.
.. py:property:: is_include
Whether the Django template tag is `include`.
.. py:property:: can_be_void
Whether the tag can be a void element.
.. py:property:: component_name
Legacy property for `tag_name`. Deprecated.