{% for item_name, item_value in document_dictionary.items() recursive -%}
{% if item_name != '#' and item_name[1] != '!include' -%}
{% if item_value is mapping -%}
{% if '#' in item_value -%}
{% for comment in item_value['#'] -%}
{{ comment }}
{% endfor -%}
{% endif -%}
{{ item_name[0] + item_name[1:] | join(' ') }} {
    {{ loop(item_value.items()) | indent}}}
{% else -%}
{% for comment in item_value[:-1] -%}
{{ comment }}
{% endfor -%}
{{ item_name[0] + item_name[1:] | join(' ') }}{%- if not item_value[-1] == '' %} = {{ item_value[-1] }}
{% else -%}
{{ '' if loop.last else '\n' -}}
{% endif -%}
{% endif -%}
{{ '' if loop.last else '\n' -}}
{% endif -%}
{% endfor -%}
{% for item_name in document_dictionary.keys() -%}
{% if item_name[1] == '!include' -%}
{{ item_name[0] + item_name[1:] | join(' ') }}
{{ '' if loop.last else '\n' -}}
{% endif -%}
{% endfor -%}
