handlebars.js 用 <br>替換掉 內容的換行符
JS:
Handlebars.registerHelper('breaklines', function(text) { text = Handlebars.Utils.escapeExpression(text); text = text.toString(); text = text.replace(/(\r\n|\n|\r)/gm, '<br>'); return new Handlebars.SafeString(text); });
HTML template:
<div> {{breaklines description}} </div>