{% import 'macro/citation.html.j2' as citation_macros %}

{% macro name_label(name, embedded=False) -%}
    <span class="person-label" typeof="foaf:Person">
    {%- if name.individual -%}
        <span property="foaf:individualName">{{ name.individual }}</span>
    {%- else -%}
        …
    {%- endif -%}
    {%- if name.affiliation %} <span property="foaf:familyName">{{ name.affiliation }}</span>
    {%- endif -%}
    </span>
    {%- if not embedded -%}
        {{ citation_macros.cite(name.citations) }}
    {%- endif -%}
{%- endmacro %}

{% macro sortable_label(person, link=True) %}
    {% if link -%}
        <a href="{{ person | url }}">
    {%- endif %}
    {% if person.private -%}
        <span class="private" title="{% trans %}This person's details are unavailable to protect their privacy.{% endtrans %}">{% trans %}private{% endtrans %}</span>
    {%- elif person.name is not none -%}
        <span class="person-label" typeof="foaf:Person">
        {%- if person.name.affiliation is not none -%}
            <span property="foaf:familyName">{{ person.name.affiliation }}</span>
        {%- else -%}
            …
        {%- endif -%}
        , {% if person.name.individual is not none -%}
            <span property="foaf:individualName">{{ person.name.individual }}</span>
        {%- else -%}
            …
        {%- endif -%}
        </span>
    {%- else -%}
        <span class="nn" title="{% trans %}This person's name is unknown.{% endtrans %}">n.n.</span>
    {%- endif -%}
    {%- if link -%}
        </a>
    {%- endif -%}
{% endmacro %}
