How to use a global helper in meteor blaze


#1

I have made a global helper inside /imports/startup/client/shared-helpers.js

Template.registerHelper('getGreetings',function(){
   let greetings = "hello world";
   return greetings;
})

how can i access this helper inside

<template name="greetingsTemplate">
    //what should be the code here
</template>

Want to make some reusable templates.


#2

You can call it the same as you’d call a helper defined on a template.

<template name="greetingsTemplate">
    {{ getGreetings }}
</template>```

#3

Thanks for the help it’s working fine. but I want to use this greetingsTemplate inside another template in other file.
like this code

<template name="someTemplate">
   {{>greetingsTemplate}}
</template>

is it right way to do so.


#4

The problem got solved. thanks for your time.:grinning:
The code worked after importing shared-helpers file.