{# This entry is evaluated on a translation-group by translation-group
basis, and so far only receives the `translation_group` node.
Differences between this template and the parent template involve:
- optional existence of tCtn node
#}
{%- macro render_annotation(tg) -%}
{# Render the annotation () node, unless it has a @fra_ref. #}
{%- set annotations = tg.xpath('./re') %}
{% set fra_ref = tg.xpath('./re/@fra_ref')|count > 0 %}
{% if annotations|count > 0 and not fra_ref %}
({{ annotations[0].text }})
{% endif -%}
{%- endmacro -%}
{%- macro render_link(tg, t) -%}
{# Render a link to the detailed page. One exception: if the lexicon
annotation entry contains a @fra_ref attribute, then we make a
reference link, inserting this attribute's value in as a parameter.
om to personer
-->
hverandre: om to personer
#}
{% set text = t.text %}
{% set link_target = '' %}
{% set fra_ref = tg.xpath('./re/@fra_ref') %}
{% if fra_ref|count > 0 %}
{# If this is a reference link, then there is no data in the
node, so the becomes the link text. #}
{% set annotations = tg.xpath('./re') %}
{% set reference = fra_ref|join('') %}
{% set text = annotations[0].text %}
{% else %}
{% set reference = false %}
{% endif %}
{% if reference %}
{{- text -}}
→
{%- else %}
{# NB: swap from and to for these links since these are definitions. #}
{{- text -}}
{%- endif %}
{%- endmacro -%}
{%- macro render_tg(tg) -%}
{# Render all the texts as individual links, followed by a potential
annotation. #}
{% set tCtns = tg.xpath("./tCtn") %}
{% set bare_t = tg.xpath('./t | ./tf') %}
{# Entries may both have nodes grouped by tCtns, and
free-standing nodes, so we need to do both. #}
{% for t in bare_t %}
{{ render_link(tg, t) -}}{% if not loop.last or tCtns|length > 0 %}, {% endif %}
{% endfor -%}
{% if tCtns %}
{% for tCtn in tCtns %}
{% set tCtn_ts = tCtn.xpath('./t | ./tf') %}
{% for t in tCtn_ts %}
{{ render_link(tCtn, t) }}{{- render_annotation(tCtn) -}}{% if not loop.last %}, {% endif %}
{% endfor %}
{% endfor %}
{% endif %}
{%- endmacro -%}
{%- if translation_group -%}
{{ render_tg(translation_group) }}
{%- endif -%}
{# vim: set ts=4 sw=4 tw=72 syntax=htmljinja : #}