How do you make a Handlebars helper that is aware of Ember bindings?

人盡茶涼 提交于 2019-12-07 05:17:44

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!