mercredi 22 avril 2015

Ember CLI + HTMLBars -- Passing Parameters to a Helper

I'm trying to pass a parameter from my HTMLBars template to a Helper.

As per the documentation, I've created a helper and explicitly registered the helper:

export default Ember.HTMLBars.makeBoundHelper('is-foo', function(value, options) {
   console.log("value: "+value);
});

But I get an error "Error: Assertion Failed: makeBoundHelper generated helpers do not support use with blocks"

So I've tried using Ember.HTMLBars.helper and Ember.HTMLBars.registerHelper as suggested here but I get errors "TypeError: Ember.default.HTMLBars.helper is not a function"

If I don't reigster the helper explicitly:

export default function(value, options) {
   console.log("value: "+value);
};

Then I can pass a parameter, but it doesn't get resolved and logs out the literal text of what I passed.

So I tried the solution outlined here but it doesn't seem to work with CLI

I'm not sure what to do next. Any help is appreciated.




Aucun commentaire:

Enregistrer un commentaire