{# Renders an ODCS v3.2.0 context block: a plain string, or instructions, verifiedStatements and constraints. #}
{% macro render_context(context) -%}
{% if context is string %}
{{ context }}
{% else %}
{% set instructions = context.instructions if context.instructions is defined and context.instructions else none %}
{% set statements = context.verifiedStatements if context.verifiedStatements is defined and context.verifiedStatements else [] %}
{% set constraints = context.constraints if context.constraints is defined and context.constraints else [] %}
{% if instructions %}
Instructions
{{ instructions }}
{% endif %}
{% if statements|length > 0 %}
Verified statements
{% for statement in statements %}
{% if statement.question is defined and statement.question %}{{ statement.question }}{% endif %}
{% if statement.answer is defined and statement.answer %}{{ statement.answer }}{% endif %}
{% if statement.tags is defined and statement.tags %}
{% for tag in statement.tags %}{{ tag }}{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
{% if constraints|length > 0 %}
Constraints
{% for constraint in constraints %}
{% if constraint.constraint is defined and constraint.constraint %}{{ constraint.constraint }}{% endif %}
{% if constraint.tags is defined and constraint.tags %}
{% for tag in constraint.tags %}{{ tag }}{% endfor %}
{% endif %}
{% if constraint.authoritativeDefinitions is defined and constraint.authoritativeDefinitions %}
{% for definition in constraint.authoritativeDefinitions %}
{% if definition.url is defined and definition.url %}
{{ definition.type if definition.type is defined and definition.type else 'link' }}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
{%- endmacro %}
{# Renders a synonyms list as "Synonyms: a, b (fr-FR)" #}
{% macro render_synonyms(synonyms) -%}
{% if synonyms and synonyms is sequence and synonyms is not string and synonyms|length > 0 %}
Synonyms:
{% for synonym in synonyms %}
{% if synonym is string %}
{{ synonym }}{% if not loop.last %},{% endif %}
{% elif synonym.synonym is defined and synonym.synonym %}
{{ synonym.synonym }}{% if synonym.locale is defined and synonym.locale %} ({{ synonym.locale }}){% endif %}{% if not loop.last %},{% endif %}
{% endif %}
{% endfor %}