Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Using pre-compiled templates with Backbone.Marionette, require.js and the tpl template plugin
define(function (require, exports, module) {
var ns = require('namespace'),
Backbone = require('use!backbone'),
Marionette = require('use!marionette'),
// the tpl require.js plugin extends the text plugin to compile the text into an underscore template
// The require.js optimizer will minify and concatenate them to your apps single JS
ordersViewTpl = require('tpl!templates/orders.html');
var Orders = ns.module();
Orders.Model = Backbone.Model.extend({});
Orders.Collection = Backbone.Collection.extend({
url: '/orders',
model: Orders.Model
Orders.Views.Details = Backbone.Marionette.ItemView.extend({
tagName: 'div',
// turns out, the signature of renderHtml matches a compiled template, so I can just
// override it with the template - simple and easy
renderHtml: orderDetailTpl
return Orders;
KevM commented May 23, 2012

Thanks I think this will help me out as I am using the same plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.