How to use Custom helpers in ember-app-kit?

i have this custom helper in app/helpers/moment-date.js

    var momentDate = Ember.Handlebars.helper('momentDate',function(date) {
      return moment(date).fromNow();
export default momentDate;

and the following handlebars in template:

{{momentDate creationDate}}

but it cause this error:

Uncaught Error:  Handlebars error: Could not find property 'momentDate' on object <(subclass of Ember.ObjectController):ember316>. 

how ember-app-kit resolves custom helpers in app/helpers??

Well if you look in the ember-app-kit-example-with-bloggr-client you see virtually the same helper but it is a Bound Helper. Syntax below and at the link.

var formatDate = Ember.Handlebars.makeBoundHelper(function(date) {
  return window.moment(date).fromNow();

export default formatDate;
1 Like

If your using a build of ember with the container-renderables feature, the way your defining the helper should be fine; but you should reference it in templates using the dasherized name (i.e. moment-date). See issue 63 for some relevant discussion.

For using a build without the container-renderables feature you need to actually import the helper module somewhere. For an example have a look at fire-up-ember-app-kit.


I tested it and registerBoundHelper but dont work

Yes i knew this and when i use the import in my controller it works same as :

import price from 'appkit/helpers/price';  

in fire-up-ember-app-kit. But i wanted to know how can ember automatically resolve this.