Created
May 2, 2012 13:08
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks I think this will help me out as I am using the same plugin