It seems you can't do it "directly"
Try use helper, why not?
Register helper in your javascript code:
Handlebars.registerHelper('ifEquals', function(arg1, arg2, options) {
return (arg1 == arg2) ? options.fn(this) : options.inverse(this);
});
Use in template:
{{#ifEquals sampleString "This is a string"}}
Your HTML here
{{/ifEquals}}
More details here:
Logical operator in a handlebars.js {{#if}} conditional
Update:
Another way:
lets assume, your data is:
var data = {
sampleString: 'This is a string'
};
Then (using jQuery):
$.extend(data, {isSampleString: function() {
return this.sampleString == 'This is a string';}
});
An use template:
{{#if isSampleString}}
Your HTML here
{{/if}}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…