Can Blaze parent templates or layouts share their helpers?


#1

Hi,

I mean, is it possible to call from an inner template a helper in the parent template or layout template?
If so, how?

Thanks


#2

You can’t directly share helpers between templates, but you can pretty easily create helpers as regular functions that can be assigned as helper functions to multiple templates.

export someFunc = function() {
  //function code
}
import someFunc from '../path/to/someFunc.js';

Template.someTemplate.helpers({
  someHelper: someFunc,
});

#3

Have a look at this nice package: