When I add <br />
to a <p>
in HTML, it doesn’t make a new line but shows “<br />”
.
Here’s any example of what it shows:
Hello <br /> World
BTW I’m using Handlebars.
I have my HTML like this:
<p>{{content}}</p>
I’m expecting it to make a new line instead of put “<br />”
I’ve tried to use <br>
but same problem.
2
Answers
By default, Handlebars escapes any HTML in the content you provide, so
<br />
becomes<br />
in the source, which then renders as <br />.You can disable the escaping by using triple braces instead of the usual double braces.
See the documentation about this at https://handlebarsjs.com/guide/#html-escaping
Handlebars escapes values returned by a
{{expression}}
. If you don’t want Handlebars to escape a value, use the "triple-stash",{{{
For more details: https://handlebarsjs.com/guide/#html-escaping