Examples¶
dj-angles
is pretty flexible when determining what HTML to parse. Here are some examples to show what can be done. Custom mappers can also be setup to handle additional use cases.
React-style include¶
# settings.py
ANGLES = {
"initial_tag_regex": r"(?=[A-Z])", # lookahead match upper-case letter
}
<PartialOne />
This would transpile to the following.
<dj-partial>{% include 'partial-one.html' %}</dj-partial>
Attributes without a dj- prefix¶
# settings.py
ANGLES = {
"initial_attribute_regex": r"(?=\w)", # lookahead match anything that starts with a letter
}
<div if="True">Example</div>
This would transpile to the following.
{% if True %}<div if="True">Example</div>{% endif %}
Attributes with a special character¶
# settings.py
ANGLES = {
"initial_attribute_regex": r"(:)",
}
<div :if="True">Example</div>
This would transpile to the following.
{% if True %}<div if="True">Example</div>{% endif %}