I am trying to implement a simple conditional statement in Handlebars that changes based on an attribute in my controller.
I managed to find:
Handlebars.registerHelper("businessVerificationState", function(state, block) {
var value = Ember.getPath(this, "state");
if (value == state) {
return block(this);
}
});
App.businessController.business refers to the model object that I created, and "state" is an attribute. Below is the template.
<script type="text/x-handlebars">
{{#with App.businessController.business}}
{{#exampleState "test1"}}
<p>Test 1</p>
{{/exampleState}}
{{#exampleState "test2"}}
<p>Test 2</p>
{{/exampleState}}
</script>
All this swells. Except when my model attributes change. From the console in webkit .. if I type ..
business.set ("state", "test2"); for example, nothing changes.
If I use other standard steering descriptors, such as IF or UNLESS, the content change is based on updating the model attributes.
Obviously, I am doing something incredibly wrong and would appreciate any help.