Created
March 2, 2012 04:47
-
-
Save tvpmb/1955761 to your computer and use it in GitHub Desktop.
fetch templates for bb layoutmanager
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
Backbone.LayoutManager.configure({ | |
paths: { | |
layout: "//app/layouts/", | |
template: "//app/templates/" | |
}, | |
fetch: function(path) { | |
path = path + ".html"; | |
path = path.slice(1); | |
window.JST = window.JST || {}; | |
// Should be an instant synchronous way of getting the template, if it | |
// exists in the JST object. | |
if (JST[path]) { | |
return Handlebars.template(JST[path]); | |
} | |
var done = this.async(); | |
/* $.ajax({ | |
url: path, | |
cache: true, | |
success: function(contents) { | |
done(Handlebars.compile(contents)); | |
} | |
}); */ | |
$.get(path, function(contents) { | |
done(Handlebars.compile(contents)); | |
}); | |
}, | |
render: function(template, context) { | |
return template(context); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment