1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-30 19:45:57 +00:00
Lidarr/NzbDrone.Backbone/Mixins/backbone.marionette.templates.js

38 lines
960 B
JavaScript
Raw Normal View History

_.extend(Marionette.TemplateCache.prototype, {
loadTemplate:function (templateId) {
var template;
console.log("Loading template '" + templateId + "'");
2013-02-18 03:04:28 +00:00
if (templateId.startsWith('#')) {
return $(templateId).html();
}
$.ajax({
2013-02-18 03:04:28 +00:00
url:'/static/' + templateId + '.html',
cache:false,
async:false
}).done(function (data) {
template = data;
}).fail(function (data) {
console.log("couldn't load template " + this.templateId + " Error: " + data.statusText);
template = "<div class='alert alert-error'>Couldn't load template '" + templateId + "'. Status: " + data.statusText + "</div>";
});
return template;
}
});
_.extend(Marionette.TemplateCache.prototype, {
compileTemplate:function (rawTemplate) {
return Handlebars.compile(rawTemplate);
}
});