Greatly simplify the jinja code for tag_object.
This commit is contained in:
parent
ae6ab72536
commit
723c96c4f2
1 changed files with 13 additions and 32 deletions
|
@ -18,40 +18,21 @@
|
||||||
extra_classes="",
|
extra_classes="",
|
||||||
innertext=None,
|
innertext=None,
|
||||||
link='search',
|
link='search',
|
||||||
|
onclick=None,
|
||||||
with_alt_description=False
|
with_alt_description=False
|
||||||
) -%}
|
) -%}
|
||||||
|
|
||||||
{%- if link is not none -%}
|
{% set href = {
|
||||||
{%- set closing="</a>" -%}
|
"search": "/search?tag_musts=" + tag.name,
|
||||||
<a
|
"info": "/tag/" + tag.name,
|
||||||
{%- if link == 'search' -%}
|
"void": "javascript:void(0)",
|
||||||
{{' '}}href="/search?tag_musts={{tag.name}}"
|
None: None,
|
||||||
{%- elif link == 'info' -%}
|
}.get(link, link)
|
||||||
{{' '}}href="/tag/{{tag.name}}"
|
%}
|
||||||
{%- elif link == 'void' -%}
|
{% set class = ("tag_object" + " " + extra_classes).strip() %}
|
||||||
{{' '}}href="javascript:void(0)"
|
{% set title = (with_alt_description and tag.description) or None %}
|
||||||
{%- else -%}
|
{% set innertext = innertext or tag.name %}
|
||||||
{{' '}}href="{{link}}"
|
|
||||||
{%- endif -%}
|
|
||||||
{%- else -%}
|
|
||||||
{% set closing="</span>" %}
|
|
||||||
<span
|
|
||||||
{%- endif -%}
|
|
||||||
|
|
||||||
{{' '}}class="tag_object {{extra_classes}}"
|
<a {{make_attributes(class=class, title=title, href=href, onclick=onclick)|safe}}>{{innertext}}</a>
|
||||||
|
{{-''-}}
|
||||||
{%- set altlines=[] -%}
|
|
||||||
{% if with_alt_description and tag.description != "" %}{% do altlines.append(tag.description) %}{% endif %}
|
|
||||||
{% set altlines=altlines|join("\n") %}
|
|
||||||
{%- if altlines -%}
|
|
||||||
{{' '}}title="{{altlines}}"
|
|
||||||
{%- endif -%}
|
|
||||||
>
|
|
||||||
{%- if innertext is not none -%}
|
|
||||||
{{innertext}}
|
|
||||||
{%- else -%}
|
|
||||||
{{tag.name}}
|
|
||||||
{%- endif %}
|
|
||||||
|
|
||||||
{{- closing|safe -}}
|
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
Loading…
Reference in a new issue