Manu
Manu

Reputation: 301

Meteor Spacebars Helpers - Passing another spacebar as helper argument

I have been trying to pass the spacebar as another spacebar argument like this :

{{helperfunction {{argument}} }}

here the {{argument}} is also coming from another helper function.

Is there any way to achieve this?

Upvotes: 1

Views: 301

Answers (1)

Winston RIley
Winston RIley

Reputation: 482

You do not need to use the additional {{}}.

lets say that argument is a string and helper function is expecting a string then {{helperFn argument}} is like helperFn(argument). So the single {{ ... }} is sufficient. {{}} using the bracket is like opening a javascript context (kind of) so if arguments is already a defined var that is in scope, there is no need to add additional {{}}.

if you do want to compose blaze helper functions, you can do that by using parens like so {{helperFn1 (helperFn2 argument)}}. this would be like helperFn1( helperFn2(argument) )

also, if argument is a function, I believe that blaze will call the function and return the result automatically. => {{helperFn argument}} is like helperFn(argument()).

hope that helps a bit.

Upvotes: 2

Related Questions