It's late and my eyes are tired, so maybe I'm missing something obvious.
If I render with a Mustache template like this...
$(container).append(Mustache.render(template, { someText: someText}));
...and my template looks like this...
<div>{{someText}}</div>
...and someText is a long string that includes one or more carriage returns, how can I convert the carriage returns to <br/> tags?
At the moment, the carriage returns are left as-is, which means the markup looks nice, but the rendered text is all bunched up.
Thanks.
To replace all carriage returns you can use:
someText = someText.replace(/\n/g,"<br />");
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