skip to Main Content

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


  1. By default, Handlebars escapes any HTML in the content you provide, so <br /> becomes &lt;br /&gt; 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

    Login or Signup to reply.
  2. Handlebars escapes values returned by a {{expression}}. If you don’t want Handlebars to escape a value, use the "triple-stash", {{{

    <p>{{{content}}}</p>
    

    For more details: https://handlebarsjs.com/guide/#html-escaping

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search