Add innertext_safe if you want to avoid escaping.

This commit is contained in:
voussoir 2020-10-25 20:24:06 -07:00
parent c9fcb51247
commit 1b221ce8be

View file

@ -19,6 +19,7 @@
tag, tag,
extra_classes="", extra_classes="",
innertext=None, innertext=None,
innertext_safe=None,
link='search', link='search',
onclick=None, onclick=None,
with_alt_description=False with_alt_description=False
@ -35,9 +36,9 @@
-%} -%}
{%- set class = ("tag_object" + " " + extra_classes).strip() -%} {%- set class = ("tag_object" + " " + extra_classes).strip() -%}
{%- set title = (with_alt_description and tag.description) or None -%} {%- set title = (with_alt_description and tag.description) or None -%}
{%- set innertext = innertext or tag.name -%} {%- set innertext = innertext_safe or (innertext or tag.name)|e -%}
{%- set element = "a" if (link or onclick) else "span" -%} {%- set element = "a" if (link or onclick) else "span" -%}
<{{element}} {{make_attributes(class=class, title=title, href=href, onclick=onclick, **kwargs)|safe}}>{{innertext}}</{{element}}> <{{element}} {{make_attributes(class=class, title=title, href=href, onclick=onclick, **kwargs)|safe}}>{{innertext|safe}}</{{element}}>
{{-''-}} {{-''-}}
{%- endmacro -%} {%- endmacro -%}