Access helpers instance, within helpers definition

Hi,
I’m using a quite unelegant way to access a preivously declared helper but is there a cleaner way ?

Template.instance().view.template.__helpers[" all"]()

in context:

Template.courses.helpers({
  all() {
    return db.find({type: 'course'}, 
    { sort: 
      {'fields.Name': 1}
    }).fetch()
  },
  unique() {

  Template.instance().view.template.__helpers[" all"]() // dirty..
  return []
  }
})

Thank you!

You can declare the function separately and reuse it. Or you could use this package (or something similar) https://atmospherejs.com/znewsham/blaze-component

1 Like