I need to display a string containing \n using Jade and I want to convert those characters in <br>. I tried to do that in two ways:
- var s = 'text\nand\ntext';
p= string
p= string.replace(/\n/g, '<br />')
But in the first case I can’t see spaces and with the second paragraph the HTML is escaped.
I solved it liked this:
It doesn’t escape html special characters but since I’m using
<meta charset="utf-8">it shouldn’t be a problem.