Created
January 17, 2012 00:07
-
-
Save tvpmb/1623731 to your computer and use it in GitHub Desktop.
Require.js Init
This file contains 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([ | |
'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({ | |
... | |
}); |
This file contains 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
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