Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ryansmith111
Created May 2, 2012 13:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryansmith111/2576421 to your computer and use it in GitHub Desktop.
Save ryansmith111/2576421 to your computer and use it in GitHub Desktop.
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
Copy link

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