Inline template into variable

If you need key and value in the loop you’d need to use .items() method on the dictionary to convert it to key-value tuples.

Also, note that whitespace is preserved in the loops, so you might not want the nesting.

Try this:

{% for section, conf in config.items() %}
{% for key, value in conf.items() %}
{{ 'GF_' + section | upper + '_' + key | upper + '=' + value }}
{% endfor %}
{% endfor %},'
2 Likes