T
T
tekleworm2018-01-30 14:59:11
Jinja
tekleworm, 2018-01-30 14:59:11

How to add \n in jinja2?

There is a code like this on Jinja

{% if item.vlans is defined and item.vlans != None %}{% for vlan in item.vlans %}vlan {{ vlan  }} media ethernet state active {%- endfor %}{%- endif %}
but it sculpts everything in one line. What can be done to add \n ? And then if you explicitly write \n at the end, then it writes it so directly. MB is there any official word?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-01-30
@tekleworm

You just need not to write the template in one line and remove the minus sign

{% if item.vlans is defined and item.vlans != None %}{% for vlan in item.vlans %}
vlan {{ vlan }} media ethernet state active
{% endfor %}{% endif %}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question