mirror of https://github.com/Sonarr/Sonarr
37 lines
1.0 KiB
JavaScript
37 lines
1.0 KiB
JavaScript
|
|
define(['underscore', 'marionette', 'handlebars', 'jquery'], function (_, Marionette, Handlebars, $) {
|
|
_.extend(Marionette.TemplateCache.prototype, {
|
|
|
|
loadTemplate: function (templateId) {
|
|
|
|
|
|
var template;
|
|
|
|
console.log("Loading template '" + templateId + "'");
|
|
|
|
$.ajax({
|
|
url: '_backboneApp//' + 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);
|
|
}
|
|
});
|
|
});
|
|
|