JavaUser JavaUser - 7 months ago 16
Javascript Question

Mustache js line break

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.

Answer

You should use <br> but in your mustache template you must use {{{myString}}} to escape html

Comments