HTMLBars custom if helper



I’m currently migrating a large code base to HTMLBars. I’m currently having trouble with a custom if helper I wrote.

{{#each arrayItem in controller.arrayOfItems}}
    {{#ifUserCanDisplayView arrayItem.value}}

Ember.HTMLBars.helper('ifCustom', function(params, hash, options, env) {
        return options.template.render(this, env, options.morph.contextualElement);

Actually, the generated html contains the part inside the if, but I cannot access anymore to the variable arrayItem.

So this is basically what I get:


Does anybody knows how it is possible with HTMLBars to bind the context outside the if helper inside it too? I’m quite lost with the new API… :confused:

Thanks in advance for your help!


Would be easier to help if you provided a simple JSBin. Would you mind whipping one together?

You can use as a starting point if you’d like…



Thank you for your answer!

I prepared a JSBin :

I actually realized I was using the prod version. With the debug version, there is one error message, but no html generated.

“Error: Assertion Failed: makeBoundHelper generated helpers do not support use with blocks”

I don’t know what are my options to pass through this problem. I saw that there are only BoundHelpers and ViewHelpers by inspecting Ember.HTMLBars object, but I can’t find an easy way to get some more information about it… :confused:


See the bottom of the page


I believe you need to use a computed property


Correct. You need to use Ember.HTMLBars.registerHelper (note this is not bound so you have to subscribe and rerender when input param changes).