mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 13:33:34 -07:00
using pre-compiled handlebar templates
re-did static content from nancy
This commit is contained in:
parent
3720afd30d
commit
375f887539
21 changed files with 367 additions and 124 deletions
|
@ -1,37 +1,23 @@
|
|||
_.extend(Marionette.TemplateCache.prototype, {
|
||||
"use strict";
|
||||
|
||||
loadTemplate:function (templateId) {
|
||||
Marionette.TemplateCache.get = function (templateId) {
|
||||
var templateFunction = window.Templates[templateId];
|
||||
|
||||
if (!templateFunction) {
|
||||
console.error('couldn\'t find pre-compiled template ' + templateId);
|
||||
}
|
||||
|
||||
var template;
|
||||
var templateName = templateId;
|
||||
|
||||
console.log("Loading template '" + templateId + "'");
|
||||
|
||||
if (templateId.startsWith('#')) {
|
||||
return $(templateId).html();
|
||||
return function (data) {
|
||||
|
||||
try {
|
||||
console.log('rendering template ' + templateName);
|
||||
return templateFunction(data);
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
catch (error) {
|
||||
console.error('template render failed for ' + templateName + ' ' + error.message);
|
||||
console.error(data);
|
||||
}
|
||||
};
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue