Billybobbonnet
Billybobbonnet

Reputation: 3226

How can I pass parameters to an helper?

I want to pass some parameters from my HTML to my meteor helper.

Can I do something like this? ->

{{myHelper "customText"}}

or

{{myHelper context="customText"}}

If so, how do I get back the string "customText"? Is it something like this? ->

"myHelper": function(context){
    return this.dataset[context]?"success":"danger"
},

thanks!

Upvotes: 0

Views: 52

Answers (1)

Rafael Quintanilha
Rafael Quintanilha

Reputation: 1432

Pass parameters to a help like this:

<template name="myTemplate">
...
{{myHelper param}}
...
</template>

Then access it in your .js file:

Template.myTemplate.helpers({
   myHelper: function(param) {
      // do anything with param
   }
});

Upvotes: 1

Related Questions