How to use multiple parameters in a handlebar helper with meteor?

后端 未结 2 890
终归单人心
终归单人心 2021-02-01 12:47

I am trying to create a custom helper using Meteor. Following to the doc here: https://github.com/meteor/meteor/wiki/Handlebars

I have tried to define my helper as foll

相关标签:
2条回答
  • 2021-02-01 13:01

    Addition to

    <template name="myTemplate"> {{testHelper "value1" "value2"}} </template>

    Instead of passing a value as a parameter pass the function as parameter Here is the code for that

    <template name="myTemplate">
        {{ testHelper1 (testHelper2 "value2") }}
    </template>
    

    cheers!!!!!

    0 讨论(0)
  • 2021-02-01 13:09

    Your logic is good, just make some changes to the template

    <template name="myTemplate">
      {{testHelper "value1" "value2"}}
    </template>
    

    Bare in mind that the testHelper function is only defined in the myTemplate template.

    If you want to register testHelper globally you'll need to do something like this

    Handlebars.registerHelper('testHelper', function(foo, bar){
      console.log(foo);
      console.log(bar);
    });
    

    Have fun

    0 讨论(0)
提交回复
热议问题