Using Handlerbars Helpers in backbone.marionette.handlebars

I have a web application using backbone.marionette with handlebars using the extension backbone.marionette.handlebars . This works well, but I want to add templateHelpers to help with formatting, and I can't get it to work.

I have included template helpers in what I think is correct (see below), but I get an error from require.js saying "GET ... / templates / helpers / foo.js 404 (NotFound)" as soon as it starts backbone.marionette app.

My template looks like this (UPDATED: Thank you, Billy Chan)

<div>{{{foo myData}}}</div>

And I tried two things. First, define a simple helper inside my Marionette.ItemView like this:

...
return Marionette.ItemView.extend({
    template: template,
    templateHelpers: {
        foo: function (someData) { return 'foo and ' + someData; }
    },
...

, .. require.js, . (: , , ).

, , ... /templates/helpers/foo.js require.js, foo . , , .. . , , . , , , .

, backbone.marionette.handlebars github. , templateHelpers , . .

UPDATE

, , {{foo}} {{{foo}}}, foo Marionette.ItemView.extend, foo. , {{foo myData}} {{{foo myData}}}, 404 Not found, . .

  • backbone 1.0.0
  • backbone.marionette 1.0.4
  • backbone.marionette.handlebars 0.2.0.
+4
1

, @BillyChan . , . , , require-handlebars-plugin .

Backbone.Marionette, registerHelper require, , , , ... /templates/helpers/xxx.js . , 404, , .

, , . , , , , Handlebars Backbone.Marionette. .

+3

All Articles