You have to mark the string as html in your helper if you want to Handlebars not to escape it. Use Handlebars.safeString
to do this. The below should suit your needs
Handlebars.registerHelper('splitQuote', function(string) {
if (string.indexOf('|') !== -1) {
return new Handlebars.SafeString(string.replace('|', '<span>') + '</span>');
}
return string;
});
As mentioned in comments you should probably escape the passed string using Handlebars.Utils.escapeExpression(string)
to encode the string before you do your custom formatting. I'd recommend writing like this:
Handlebars.registerHelper('splitQuote', function(string) {
string = Handlebars.Utils.escapeExpression(string);
if (string.indexOf('|') !== -1) {
string = string.replace('|', '<span>') + '</span>';
}
return new Handlebars.SafeString(string); // mark as already escaped
});