3

I have a form with textfields in Flask, and users enter texts line by line. When I look at the DB the enties are stored with line breaks but when I display it on my website, in Flask templates, it just joins the sentences and I couldn't display the text line by line anymore.

To illustrate, user enters text as

1

2

3

However, it looks like in my page as:

1 2 3

This is my code in the template:

{{ vroute.comments }}
Bassie
  • 83
  • 9

2 Answers2

7

Try

<pre>{{ vroute.comments }}</pre>

HTML collapses whitespace unless you indicate otherwise.

Jasmijn
  • 9,370
  • 2
  • 29
  • 43
0

please add:

style="white-space: pre-line"

to your html tag, for example

<span style="white-space: pre-line"> {{ vroute.commnets}}</span>
Vahid Rafael
  • 29
  • 1
  • 3