2

In a Meteor application, suppose I have the following template:

Template.templateName.helpers({
  helper1: function () {
    alert("helper function called")
  }
}

How do I call the helper1 function from the browser console?


EDIT: This is one solution:

Template.templateName.__helpers[" helper1"]() 

Is there a more orthodox way?

James Newton
  • 6,623
  • 8
  • 49
  • 113
  • Great question. I tried the above code and it works. However I was wondering why the space in " helper1" is necessary? – Nate Aug 19 '15 at 13:25
  • My guess is that this is done deliberately to prevent you from using `Template.templateName.__helpers.helper1()`, because you're not supposed doing this in production. – James Newton Aug 19 '15 at 14:47
  • Makes sense. I am able to call a global helper with `UI._globalHelpers['userProfileInfo'](Meteor.userId())` from the browser console, where `userProfileInfo` is defined as `Template.registerHelper('userProfileInfo', function (userId) {` – Nate Aug 19 '15 at 15:16
  • possible duplicate of [How do you call a Meteor template helper from the console or other JS code?](http://stackoverflow.com/questions/32042886/how-do-you-call-a-meteor-template-helper-from-the-console-or-other-js-code) – Tomasz Lenarcik Aug 19 '15 at 16:45
  • This problem is already covered here: http://stackoverflow.com/questions/32042886/how-do-you-call-a-meteor-template-helper-from-the-console-or-other-js-code/32045085#32045085 – Tomasz Lenarcik Aug 19 '15 at 16:46

0 Answers0