How do I Register Meteor Spacebars Helpers?

笑着哭i 提交于 2019-11-30 19:01:56

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/13062463/how-do-i-register-meteor-spacebars-helpers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!