Files
Prowlarr-Prowlarr/src/UI/Handlebars/backbone.marionette.templates.js
Keivan Beigi 0ee5261a2a stripBom
2015-01-29 18:10:16 -08:00

45 lines
1.4 KiB
JavaScript

'use strict';
define(
[
'templates',
'handlebars',
'handlebars.helpers',
'Handlebars/Helpers/DateTime',
'Handlebars/Helpers/Html',
'Handlebars/Helpers/Numbers',
'Handlebars/Helpers/Episode',
'Handlebars/Helpers/Series',
'Handlebars/Helpers/Quality',
'Handlebars/Helpers/System',
'Handlebars/Helpers/EachReverse',
'Handlebars/Helpers/String',
'Handlebars/Handlebars.Debug'
], function (Templates, Handlebars) {
return function () {
this.get = function (templateId) {
var templateKey = templateId.toLowerCase().replace('template', '');
var templateFunction = Templates[templateKey];
if (!templateFunction) {
throw 'couldn\'t find pre-compiled template ' + templateKey;
}
return function (data) {
try {
var wrappedTemplate = Handlebars.template.call(Handlebars, templateFunction);
return wrappedTemplate(data);
}
catch (error) {
console.error('template render failed for ' + templateKey + ' ' + error);
console.error(data);
throw error;
}
};
};
};
});