问题
When I try to pass an Ember binding or computed property to a custom Handlebars helper, the helper receives the string instead of the value. How do I get the value into the helper?
The template:
{{my_helper my.binding}}
The helper receives "my.binding" instead of the corresponding value.
回答1:
A few days ago a push on the master solved the problem : use Ember.Handlebars.registerBoundHelper.
Ember.Handlebars.registerBoundHelper('myHelper',
function(myBinding, options) {
return myDealWith(myBinding);
}
);
回答2:
You have to use Ember.getPath to get the value in helper method.
See the docs http://emberjs.com/documentation/#toc_writing-custom-helpers
来源:https://stackoverflow.com/questions/10856216/how-do-you-make-a-handlebars-helper-that-is-aware-of-ember-bindings