2

Trying to make some simple handlebars helpers

Handlebars.registerHelper('if_eq', function(context, options) {
  if (context == options.hash.compare)
    return options.fn(this);
  return options.inverse(this);
});

Getting this error.

ReferenceError: Handlebars is not defined

What's the correct way to do it.

2
  • This also happens when you are writing a package and forget the api.use('handlebars', 'client') in package.js.
    – nalply
    Commented Dec 26, 2013 at 16:57
  • Same cause, similar error: Object #<Object> has no method 'registerHelper' Commented Feb 21, 2014 at 10:47

1 Answer 1

5

the Handlebars object is only available on the client. So make sure you have if (Meteor.isClient) { } wrapped around the helper registration code

2
  • 1
    it doesn't seem to be the case, meteor templates are run on both the client and the server?
    – Harry
    Commented Oct 25, 2012 at 16:04
  • @Harry: templates for now are only run on the client - see Meteor's roadmap on Trello. Commented Feb 21, 2014 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.