registerBoundHelper does not seem to work with extra dependencies


#1

I am trying to leverage the third parameter (extra dependencies) when registering a bound helper (Ember.Handlebars.registerBoundHelper#toc_example-with-extra-dependencies) for creating a translation helper, however I cannot seem to get it working. Here is a jsbin demo:

Am I doing something wrong, or is this a bug?


#2

I had a look at the source code of registerBoundHelper. It seems that when the first parameter passed to the helper is a string (which is the case in the jsbin) then the extra dependencies are ignored (method returns before). If the first parameter is not a string (like if it was referring directly to a model parameter) then the extra dependencies are added as sub-dependencies of the first parameter. I don’t really understand the reason of doing this and/or can somebody provide a working example of this extra dependencies parameter?


#3

I’ve struggled with this too, but this is what I’ve found. The extra dependencies are the names of the properties of the first parameter which, when changed, should re-render the helper. I’ve modified your example to illustrate.

Basically, this is helpful when you want to pass a single object into a helper, but the helper output is dependent on multiple properties and should re-render when any of those properties changes. As you can see from my example, when you change either select, the helper output updates.