Allow custom innertext besides just the tag's name.
This commit is contained in:
parent
e6a50500b9
commit
b3c9dd58f5
1 changed files with 19 additions and 9 deletions
|
@ -2,6 +2,9 @@
|
||||||
tag: The Tag object
|
tag: The Tag object
|
||||||
extra_classes:
|
extra_classes:
|
||||||
Space-separated string, if you want more than "tag_object".
|
Space-separated string, if you want more than "tag_object".
|
||||||
|
innertext:
|
||||||
|
A string to use as the innertext.
|
||||||
|
Otherwise, will use the name based on the other parameters.
|
||||||
link:
|
link:
|
||||||
None = no link, just a <span>
|
None = no link, just a <span>
|
||||||
'search' = link to /search?tag_musts=tagname
|
'search' = link to /search?tag_musts=tagname
|
||||||
|
@ -14,7 +17,7 @@
|
||||||
If the tag's own name can't find under the limit, characters are
|
If the tag's own name can't find under the limit, characters are
|
||||||
dropped from the right.
|
dropped from the right.
|
||||||
qualified_name:
|
qualified_name:
|
||||||
True: Use the qualified name as the innerhtml
|
True: Use the qualified name as the innertext
|
||||||
False: Use the basic name
|
False: Use the basic name
|
||||||
with_alt_description:
|
with_alt_description:
|
||||||
True: Include the description in the alt text
|
True: Include the description in the alt text
|
||||||
|
@ -24,6 +27,7 @@
|
||||||
{% macro tag_object(
|
{% macro tag_object(
|
||||||
tag,
|
tag,
|
||||||
extra_classes="",
|
extra_classes="",
|
||||||
|
innertext=None,
|
||||||
link='search',
|
link='search',
|
||||||
max_len=None,
|
max_len=None,
|
||||||
qualified_name=True,
|
qualified_name=True,
|
||||||
|
@ -42,13 +46,15 @@
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
{{' '}}href="{{search}}"
|
{{' '}}href="{{search}}"
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{{' '}}target="_blank" class="tag_object {{extra_classes}}"
|
{{' '}}target="_blank"
|
||||||
|
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
{% set closing="</span>" %}
|
{% set closing="</span>" %}
|
||||||
<span
|
<span
|
||||||
|
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
|
|
||||||
|
{{' '}}class="tag_object {{extra_classes}}"
|
||||||
|
|
||||||
{% set altlines=[] %}
|
{% set altlines=[] %}
|
||||||
{% if with_alt_qualified_name %}{% do altlines.append(tag.qualified_name()) %}{% endif %}
|
{% if with_alt_qualified_name %}{% do altlines.append(tag.qualified_name()) %}{% endif %}
|
||||||
{% if with_alt_description and tag.description != "" %}{% do altlines.append(tag.description) %}{% endif %}
|
{% if with_alt_description and tag.description != "" %}{% do altlines.append(tag.description) %}{% endif %}
|
||||||
|
@ -57,6 +63,9 @@
|
||||||
{{' '}}title="{{altlines}}"
|
{{' '}}title="{{altlines}}"
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
>
|
>
|
||||||
|
{%- if innertext is not none -%}
|
||||||
|
{{innertext}}
|
||||||
|
{%- else -%}
|
||||||
{%- if qualified_name -%}
|
{%- if qualified_name -%}
|
||||||
{{tag.qualified_name(max_len=max_len)}}
|
{{tag.qualified_name(max_len=max_len)}}
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
|
@ -66,6 +75,7 @@
|
||||||
{{tag.name}}
|
{{tag.name}}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{{- closing|safe -}}
|
{{- closing|safe -}}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
Loading…
Reference in a new issue