Use Handlebars in EmberJS


I am trying to use a custom helper in my Ember project. So I have done bower install --save handlebars

and then under helpers\compare.js, I have

import Handlebars from 'handlebars';

Handlebars.registerHelper('compare', function (lvalue, rvalue, options) {

Is this the correct way to import Handlebars js and use it inside helper ?

Above is giving error…Could not find module handlebars


No, you probably don’t want to import handlebars or use raw handlebars helpers.

But it is very simple to add your own helper to Ember directly. Just make app/helpers/compare.js and put in:

export default Ember.Helper.helper(function([lvalue, rvalue], options) {
    return lvalue > rvalue;