I am passing a text with line break to mustache but while rendering the line breaks are not shown. Please let me know , how to add line breaks in the text.
var test ="test1"+"\n"+"test2"+"\n"+"test3".
I am passing this to Mustache for rendering and expecting this should get printed like
test1
test2
test3
But the actual result is test1test2test3
while rendering this.
Thanks.
You should use <br>
but in your mustache template you must use {{{myString}}}
to escape html
The best approach, in my opinion, is to apply the following CSS to the element you want to show with line breaks:
white-space: pre;
That way, all the \n
will actually show as line breaks. There are also other ways of handling this, for example see Mustache.js allow only line breaks, escape other HTML.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With