handlebars-lang / handlebars.js

Minimal templating on steroids.
http://handlebarsjs.com
MIT License
17.94k stars 2.04k forks source link

Be able to globally allow \n characters, convert to <br /> #1738

Open jpike88 opened 3 years ago

jpike88 commented 3 years ago

I use handlebars with Mpdf, which reads html and converts to pdf.

I have a large set of values, SOME may have newlines in them \n, some may not. They currently do not carry through, meaning some values will not have their new lines represented properly.

I'm currently stuck with two choices, both are ugly workarounds:

New line characters are a special case in HTML as they don't really correspond to HTML entities the same way other special characters do. An ability to passive convert values in two brackets placeholders to <br /> is the truest way to handle a situation like this. Even if it's just opt-in, I think it would be extremely useful.

ErfanKamalian commented 2 years ago

1805

nknapp commented 2 years ago

Some things to consider: