HTMLBars: bound block helper


With handlebars i have this helper:

Ember.Handlebars.registerHelper('isGranted', function(action,options) {
    return[0], "user.actions", options, true, function(result) {
        return App.userManager.get("current").isGranted(action);

I know it doesn’t deserve a beauty price, but it worked.

With htmlbars, the method doesn’t work anymore. How can i make this work with htmlbars? What i want: – template —

<h1>Nice template </h1>
{{#isGranted 'specialRole'}}
  You have access

this should ask user.isGranted(); to check the access, but i want to bind it to user.actions, because if the actions change, it should check again.

Any idea’s how to fix this helper in ember 1.11.1 ?

Does somebody know an answer?

I was just dealing with this same issue. You need to use the new if syntax. {{#if (helper [arguments])}}

So register your helper with:

  return App.userManager.get("current").isGranted(params[0]);

Then use:

{{#if (isGranted 'specialRole')}}
  You have access

That’s what worked for me anyways. Good luck!

1 Like