I create comments with user input and render them using Mustache.js after the user clicks the submit button. I understand that I can replace input line breaks ( \n ) with <br/> to render as HTML breaks like
myString.replace(/\n/g, '<br />');
and I understand that I can make Mustache not avoid HTML using triple brackets
{{{myString}}}
However, I would like to avoid all custom HTML, as Mustache would usually do with double brackets {{ ... }} , except for resolving line breaks with <br/>
What is the best way to do this? I can replace line breaks after rendering it, but this seems like a very inefficient solution, and I think there should be a better way.
javascript mustache
Ryan
source share