python - How to print the \n character in Jinja2 -


i have following string in python: thestring = "123\n456"

in jinja2 template, use {{thestring}} , output is:

123
456

the way can jinja2 print exact representation 123\n456 (including \n) escaping thestring = "123\\n456".

is there other way can done directly in template?

i'll answer own, maybe helps has same question.

this works: {{thestring.encode('string_escape')}}


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -