html - Rendering newline in text for a div when working with Flask as the backend? -


this question has answer here:

i using flask backend , reading piece of text file contains newlines \n. wish render text inside div. so, replacing \n <br> , passing render_template() method.

@app.route('/') @app.route('/index') def index():         content = read_file('filename.csv')          content = content.replace('\\n','<br>')         return render_tempate('index.html',text=content) 

however, doing shows br tag text. underlying html shows br tag being interpreted &lt;br&gt;

<div>some text &lt;br&gt; more text</br>

how can fix , render newline inside div?

in index.html, change {{text}} tags {{text|safe}}. default, html strings escaped in render_template, , |safe needed turn off.


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

minify - Minimizing css files -

php - How to remove letter in front of the word laravel -