vendredi 16 octobre 2015

Ember 2.0 handlebars helper is not a function?

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?

Aucun commentaire:

Enregistrer un commentaire