I have a controller object that’s like:
MyApp.objController = Ember.ArrayController.create({
init: function(data) {
data.isValid = function() {
return (data.validity === "valid");
}
this.pushObject(MyApp.MyObj.create(data));
}
});
My view is like:
{{#each MyApp.objController}}
{{#if isValid}}
<some markup>
{{else}}
<some other markup>
{{/if}}
{{/each}}
I was assuming that the if conditional in Handlebars accepts both values and functions, but this doesn’t seem to be the case. Is it actually possible, and I’m just doing it wrong?
If you define your
isValidas aproperty, you can use it in yourifstatement without creating a custom Handlebars helper, see http://jsfiddle.net/pangratz666/Dq6ZY/:Handlebars:
JavaScript: