Handlebars loading external template #544

engram-design opened this Issue Mar 28, 2013 · 2 comments


None yet
3 participants

Just wondering if its possible to do the following with external templates:

    template: 'templates/index'

Currently, I'm doing the following, which works, but just a little extra work!

], function(App, Template) {
        template: Template

Being very new to backbone.marionette, you'll have to forgive my ignorance. I've seen past posts regarding backbone.marionette.async, but that it's bad practice shouldn't be used (fair enough). In fact, this question is based from working with backbone.layoutmanager which does exactly what was suggested utilizing JST goodness.

No dramas if this isn't supported, just thought to ask. It's a fantastic framework!


cobbweb commented Mar 28, 2013

Template rendering can't be done asynchronously internally in Marionette. If you're using AMD you have to load it through that.

If you want the sweet and short version you provided, I'd recommended pre-compiling all your templates with a watch task using grunt or something.

You'll probably have to override some parts of Backbone.Marionette.Renderer and/or Backbone.Marionette.TemplateCache to get it to load them though.

Also forgot to mention I'm compiling templates as per the wiki:

Backbone.Marionette.TemplateCache.prototype.compileTemplate = function(rawTemplate) {
    return Handlebars.compile(rawTemplate);

I think I'll start looking at a grunt task to pre-compile templates!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment