htmy.etree
ETreeConverter
Utility for converting XML strings to custom components.
Source code in htmy/etree.py
_htmy_fragment = 'htmy_fragment'
class-attribute
Placeholder tag name that's used to wrap possibly multi-root XML snippets into a valid XML document with a single root that can be processed by standard tools.
__init__(rules)
Initialization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rules
|
Mapping[str, Callable[..., ComponentType]]
|
Tag-name to component conversion rules. |
required |
_convert_children(element)
Generator that converts all (text and Element
) children of the given Element
to a component.
Source code in htmy/etree.py
_convert_properties(element)
Converts the attributes of the given Element
to a Properties
mapping.
This method should not alter property names in any way.
Source code in htmy/etree.py
_process_text(escaped_text)
convert(element)
Converts the given (possibly multi-root) XML string to a component.
Source code in htmy/etree.py
convert_element(element)
Converts the given Element
to a component.