{# Render value only if it is defined #}
{% macro reformat(pattern, data) %}
    {% if data is defined %}
        {{- pattern|format(data) -}}
    {% endif %}
{% endmacro %}

{# Convert a bool value to a lowercase represenatation,
    other types passed without change
#}
{% macro mbool(input) -%}
    {%- if input is sameas true -%}
        true
    {%- elif input is sameas false -%}
        false
    {%- else -%}
        {{ input }}
    {%- endif -%}
{%- endmacro %}

{# Same as mbool (convert bool value to lowercase representation),
    but other values are double quoted "value".
#}
{% macro mbool_double_quote(input) -%}
    {%- if input is sameas true -%}
        true
    {%- elif input is sameas false -%}
        false
    {%- else -%}
        "{{ input }}"
    {%- endif -%}
{%- endmacro %}
