Skip to content

Instantly share code, notes, and snippets.

@tvpmb
Created January 17, 2012 00:07
Show Gist options
  • Save tvpmb/1623731 to your computer and use it in GitHub Desktop.
Save tvpmb/1623731 to your computer and use it in GitHub Desktop.
Require.js Init
define([
'backbone',
], function(Backbone){
Backbone.LayoutManager.configure({
// Override render to use Handlebars
render: function(template, context) {
return Handlebars.compile(template)(context);
},
paths: {
layout: "../templates/layouts/",
template: "../templates/"
},
fetch: function(path) {
var done = this.async();
$.get(path + ".html", function(contents) {
done(contents);
});
},
render: function(template, context) {
return Handlebars.compile(template)(context);
}
});
var Router = Backbone.Router.extend({
...
});
require.config({
paths: {
...
},
backbone: {
deps: ["underscore", "jquery", "handlebars"],
attach: "Backbone"
},
underscore: {
attach: "_"
},
jquery: {
attach: "$"
},
handlebars: {
attach: "Handlebars"
},
"libs/backbone/backbone.layoutmanager": {
deps: ["backbone"]
},
});
require(['views/app'], function(Router){
var router = new Router;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment