dimanche 27 décembre 2015

Generate Helper handlebars in ember-cli

I have followed the ember guide to create an handlebar helper like in this jsbin

This is the helper

Ember.Handlebars.registerBoundHelper('format-date', function(format, date) {
  return moment(date).format(format);
});

I can successfully reuse in my jsbin but i get an error when i apply the same helper in my application, this is the error Uncaught TypeError: fn.apply is not a function in my helper function , i am not implementing it correctly in my ember-cli

This is the same helper in my application

import Ember from 'ember';

export default Ember.Handlebars.registerBoundHelper('format-date', function(format, date) {
        return moment(date).format(format);
});

What's the problem?

Just to let you know i have generated the ember helper in these steps

1) From command prompt run ember generate helper "format-date"

This was the helper generated

import Ember from 'ember';

export function formatDate(params/*, hash*/) {
  return params;
}

I am definitely mistaking the way i am exporting the format-date helper

How it should be in my ember-cli?




Aucun commentaire:

Enregistrer un commentaire