python - Jinja - Indentation in a recursive loop with dictionary -
i'm trying write template using ninja. can't display right indentation! tried lot of stuffs couldn't expected result. have dictionary this:
videonode = {'type': "videoloader", 'config': {'type': "url", 'source': "blabla", 'framebuffersize': 50, } } i display that
queuevideo1: type: videoloader config: source: blabla type: url framebuffersize: 50 but can is:
queuevideo1: type: videoloader config: source: blabla type: url framebuffersize: 50 here file:
{%- key, value in videonodes.iteritems() recursive -%} {%+ if value mapping -%} {{ key }}: {{ loop(value.iteritems()) }} {%- else -%} {{ key }}: {{value}} {% endif %} {%- endfor -%}
you must try using indent function , asign value depends of level of indentation:
{{ key|indent(2, true) }} you can see the documentation here
Comments
Post a Comment