{# This entry is evaluated on a translation-group by translation-group
basis, and so far only receives the `translation_group` node.
The intent here is to make it easier to insert additional text
without needing to alter or understand the larger amount of HTML. See
`sme` for an example of including the @reg attribute.
#}
{%- 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. #}
{% for t in tg.xpath('./t') %}
{{ render_link(tg, t) -}}{% if not loop.last %}, {% endif %}
{% endfor %}
{{- render_annotation(tg) -}}
{%- endmacro -%}
{%- if translation_group -%}
{{ render_tg(translation_group) }}
{%- endif -%}
{# vim: set ts=4 sw=4 tw=72 syntax=htmljinja : #}