Handlebars.js disable escaping with noEscape option?

Suppose,

var template = "This is {{target}}";
var target = "user's pictures";
var result = Handlerbars.compile(template, {noEscape:true})({target:target});

Now try to print result. There is an apostrophe in target string value. Which will not change by encoded string. If you will remove the {noEscape:true}from compile function then it will change.


Using the "triple-stash" {{{ is another option when you only want one variable in the template to not get escaped:

Handlebars HTML-escapes values returned by a {{expression}}. If you don't want Handlebars to escape a value, use the "triple-stash", {{{.

https://handlebarsjs.com/


Try something like this:

var template = Handlebars.compile(source, {noEscape: true});