Reputation: 6703
Have been looking for a few hours a fix for this without any solution. I am trying to create a custom Ember handlebar helper using:
Ember.Handlebars.helper('highlight', function(value, options) {
var escaped = Handlebars.Utils.escapeExpression(value);
return new Ember.Handlebars.SafeString('<span class="highlight">' + escaped + '</span>');
});
But for some reason I get Uncaught TypeError: Ember.Handlebars.helper is not a function
I read that in Ember 2 they have a new approach:
// app/helpers/full-name.js
import Ember from "ember";
export default Ember.Helper.helper(function(params, hash) {
return params.join(' ');
});
But this is if you are using ember-cli, how about to register helper without ember-cli?
Upvotes: 0
Views: 1906
Reputation: 10719
In version 2 they removed all Ember.Handlebars interface calls.
Use the new helper:
Ember.Helper.helper(function(params) {
});
or extend the Ember.Helper
Ember.Helper.extend({
// This service name is only an example
compute(params, hash) {
return this.get('nameBuilder').build(params, hash.title);
},
rebuildName: Ember.observer('nameBuilder.isAnonymized', function() {
this.recompute();
})
});
Ideally you should also use ember-cli, it's easier, as i'm not sure how you compile and get everything running without it (it's a really good build system and you can make it work with any backend service you want using
ember serve --proxy
Ember Cli
Upvotes: 1