yeoman / generator-backbone

Scaffold out a Backbone.js project
http://yeoman.io
638 stars 157 forks source link

Registering handlebars helpers #331

Closed lucasdavila closed 9 years ago

lucasdavila commented 9 years ago

Hi Guys!

I created a backbone app with this generator some time ago, and now I want to use a custom handlebars helper.

So I created this helper:

// scripts/templates/helpers/foo.js
define([
  'handlebars'
], function (Handlebars) {
  'use strict';

  Handlebars.registerHelper('foo', function(date) {
    return 'foo';
  });

});

And called it on my template:

<div>{{foo attribute}}</div>

But the app is falling with Uncaught Error: Missing helper: 'format_date'.

I guess it is falling because the helpers aren't registered by handlebars yet, so I tried to change my Gruntfile.js to watch and compile the /scripts/templates/helpers folder, but the problem still happening.

I know it is more a handlebars question than a generator-backbone, but since I generated the app using this generator, I think you could help me figure out what I'm missing here :)

Thank you.

sindresorhus commented 9 years ago

Support questions are better asked on StackOverflow: http://stackoverflow.com/questions/tagged/gruntjs Paste in the link to the question here so others can follow ;)