{% set anchor_map = {} %}
{% if grouped_view and sections %}
{% for section in sections %}
{% for ent in section.entities %}
{% set precise_key = ent.uri ~ '|' ~ ent.type.lower() %}
{% set _ = anchor_map.update({precise_key: ent.anchor_id}) %}
{% if ent.uri not in anchor_map %}
{% set _ = anchor_map.update({ent.uri: ent.anchor_id}) %}
{% endif %}
{% endfor %}
{% endfor %}
{% elif single_resource and entities %}
{% for ent in entities %}
{% set precise_key = ent.uri ~ '|' ~ ent.type.lower() %}
{% set _ = anchor_map.update({precise_key: ent.anchor_id}) %}
{% if ent.uri not in anchor_map %}
{% set _ = anchor_map.update({ent.uri: ent.anchor_id}) %}
{% endif %}
{% endfor %}
{% endif %}
{% if grouped_view %}
{% set display_sections = sections %}
{% else %}
{% set display_sections = [{'is_single_view': true, 'entities': entities}] %}
{% endif %}
{% set lang_map = {
'en': 'English', 'es': 'Spanish', 'pt': 'Portuguese',
'fr': 'French', 'de': 'German', 'it': 'Italian',
'zh': 'Chinese', 'ja': 'Japanese', 'ru': 'Russian',
'ar': 'Arabic', 'nl': 'Dutch', 'ko': 'Korean', 'fa': 'Persian'
} %}
{% set md_types = ['Literal', 'Str', 'literal', 'str', 'string'] %}
{# after the sets above: "with context" only sees variables defined before the import #}
{% from '_value.html' import render_value with context %}
{% include '_toc_sidebar.html' %}
{% if not single_resource %}
{% endif %}
{% if metadata %}
{% if single_resource %}
{% set current = entities[0] if entities else None %}
{{ current.label if current and current.label else (current.uri if current else '') }}
{{ current.uri if current else '' }}
as defined in
{% if metadata.title %}
{% for title in metadata.title %}{{ title.text }}{% endfor %}
{% elif metadata.label %}{{ metadata.label[0].text }}
{% endif %}
{% else %}
{% if metadata.title %}
{% for title in metadata.title %}
{{ title.text }}
{% endfor %}
{% elif metadata.label %}
{{ metadata.label[0].text }}
{% endif %}
{{ metadata.uri[0].link }}
{% endif %}
{% for key, val_list in metadata.items() %}
{% if key not in ['uri', 'label', '_namespaces'] %}
{% if val_list %}
{{ key }}
{% for item in val_list %}
{% set v_type = item.type.lower() if item.type else '' %}
{% set is_md = v_type in md_types %}