Search code examples
meteormeteor-blazespacebars

In Meteor, Is there a way to use multiple helpers even if one can handle multiple arguments?


In my meteor project, I have multiple helpers. helper1 can handle multiple arguments but he's fine even with a single argument. The problem is I want to chain this handler with the result of another one (helper2), which also takes an argument (the actual user data). So I wrote the following :

{{helper1 helper2 currentUser}}

The problem is that helper1 seems to get two arguments : the result of helper2, and the currentUser, which means helper2 doesn't get the currentHelper argument.

I tried to use parenthesis so that everyone can get its own arguments, like that :

{{helper1 helper2(currentUser)}} or {{helper1 (helper2 currentUser)}}

Or even brackets :

{{helper1 {{helper2 currentUser}}}}

But I get a syntax error with all these workarounds. Is there any working way to do this ?


Solution

  • I finally found a solution to this problem – using #with:

    {{#with firstHelper data}}
      {{secondHelper this}}
    {{/with}}