<!--
    tag: The Tag object
    extra_classes:
        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:
        None = no link, just a <span>
        'search' = link to /search?tag_musts=tagname
        'info' = link to /tags/tagname
    with_alt_description:
        True: Include the description in the alt text
-->
{% macro tag_object(
    tag,
    extra_classes="",
    innertext=None,
    link='search',
    onclick=None,
    with_alt_description=False
) -%}

{% set href = {
        "search": "/search?tag_musts=" + tag.name,
        "info": "/tag/" + tag.name,
        None: None,
    }.get(link, link)
%}
{% set class = ("tag_object" + " " + extra_classes).strip() %}
{% set title = (with_alt_description and tag.description) or None %}
{% set innertext = innertext or tag.name %}

<a {{make_attributes(class=class, title=title, href=href, onclick=onclick)|safe}}>{{innertext}}</a>
{{-''-}}
{% endmacro %}

<!--
    tag: The Tag object
    extra_classes:
        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:
        None = no link, just a <span>
        'search' = link to /search?tag_musts=tagname
        'info' = link to /tags/tagname
    with_alt_description:
        True: Include the description in the alt text
-->
{% macro tag_object(
    tag,
    extra_classes="",
    innertext=None,
    link='search',
    onclick=None,
    with_alt_description=False
) -%}

{% set href = {
        "search": "/search?tag_musts=" + tag.name,
        "info": "/tag/" + tag.name,
        None: None,
    }.get(link, link)
%}
{% set class = ("tag_object" + " " + extra_classes).strip() %}
{% set title = (with_alt_description and tag.description) or None %}
{% set innertext = innertext or tag.name %}
{% set element = "a" if (link or onclick) else "span" %}

<{{element}} {{make_attributes(class=class, title=title, href=href, onclick=onclick)|safe}}>{{innertext}}</{{element}}>
{{-''-}}
{% endmacro %}

Use <span> for tag objects with no link or onclick.
Use <span> for tag objects with no link or onclick.

To suppress the pointy <a> tags, you know.
