ollien ollien - 4 months ago 13
Python Question

New lines in flask within {%block content%}

So if I were to do something like

{% block content %}
{{variable}}
{% endblock %}

in my HTML, and
variable
is equal to
"Test <br /> test2"
how come the
prints out and does not make a new line? is there a way to fix this?

Answer

Jinja2 automatically escapes special characters for you. Probably simplest way is to use safe filter:

{{ variable|safe }}
Comments