formula-postfix/postfix/files/mapping.j2
Gilles Dartiguelongue e10ad0e745 Make prope use of jinja templating features
join is available in jinja-2.6, released in 2011.
2016-06-20 19:02:41 +02:00

21 lines
602 B
Django/Jinja

# Managed by config management
{%- macro format_value(key, value) %}
{#- Some settings, like virtual_alias_maps can take multiple values. Handle this case. -#}
{%- if value is iterable and value is not string -%}
{{ key }} {{ value|join(", ") }}
{%- else -%}
{{ key }} {{ value }}
{%- endif -%}
{%- endmacro %}
{%- if data is mapping %}
{% for key, value in data.iteritems() %}
{{ format_value(key, value) }}
{%- endfor -%}
{%- else %}
{#- Some settings need order, handle OrderedDict #}
{% for item in data %}
{{ format_value(item.keys()[0], item.values()[0]) }}
{%- endfor -%}
{%- endif %}