I have a json file crud app with flask, I do see the new lines "\n" on the json file or when I access it on python interpreter.
>>> for i in d:
... if i['tag']=="flask":
... i
...
'tag': 'flask', 'head': 'multiline test', 'data': 'app.jinja_env.keep_trailing_newline=True\n# line2'}
{'tag': 'flask', 'head': 'multiline test3', 'data': 'st1\r\nst2'}
However, when on the html template \n are not preserved despite setting the keep trailing newline as true. Am I missing something here? I need to preserve the new lines on html - how can I do this ?
# app.py
from jinja2 import Environment
TEMPLATE_ENVIRONMENT = Environment(
keep_trailing_newline=True)
# html
{%for j in d%}
{{j['data']}}
{%endfor%}
Below are the outputs I get on browser, note that the same dictionary shows a \n and the actual file shows \n too.
app.jinja_env.keep_trailing_newline=True # line2
st1 st2