Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 549
hekevintran Avatar asked Jun 01 '12 19:06

hekevintran


2 Answers

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);
    }
);
like image 197
Chris Avatar answered Sep 19 '22 14:09

Chris


You have to use Ember.getPath to get the value in helper method.
See the docs http://emberjs.com/documentation/#toc_writing-custom-helpers

like image 43
Manoharan Avatar answered Sep 22 '22 14:09

Manoharan