Fn.apply is not a function - trying to create a Handlebars helper


#1

I create the file app/helpers/test-helper.js:

import Ember from 'ember';

export default Ember.Handlebars.registerBoundHelper('test-helper', function() {
  return "Works!";
});

And in the template:

{{test-helper}}

And I get the above error in the console. What am I doing wrong here?


#2

I tried using makeBoundHelper from HTMLBars and Ember.Helper.helper both of which kept failing with ember 1.13 with the same error as you’ve mentioned. I was using ember-cli-auto-register-helpers earlier, removing that fixed the issue.


#3
// app/helpers/test-helper.js
import Ember from 'ember';

export default Ember.Handlebars.makeBoundHelper(function() {
  return "Works!";
});

Side note, if you’re on 1.13.x you should check out the new Ember.Helper API http://emberjs.com/blog/2015/06/12/ember-1-13-0-released.html#toc_new-ember-js-helper-api