2013-06-24 21:43:16 -07:00
|
|
|
|
'use strict';
|
2013-06-24 16:41:59 -07:00
|
|
|
|
define(
|
|
|
|
|
[
|
2013-06-24 21:43:16 -07:00
|
|
|
|
'templates',
|
2013-06-26 17:29:48 -07:00
|
|
|
|
'handlebars.helpers',
|
2013-06-24 21:43:16 -07:00
|
|
|
|
'Handlebars/Helpers/DateTime',
|
|
|
|
|
'Handlebars/Helpers/Html',
|
|
|
|
|
'Handlebars/Helpers/Numbers',
|
2013-07-16 16:54:45 -07:00
|
|
|
|
'Handlebars/Helpers/Episode',
|
|
|
|
|
'Handlebars/Helpers/Series',
|
|
|
|
|
'Handlebars/Helpers/Quality',
|
2013-07-24 17:45:05 -07:00
|
|
|
|
'Handlebars/Handlebars.Debug'
|
2013-06-24 16:41:59 -07:00
|
|
|
|
], function (Templates) {
|
|
|
|
|
return function () {
|
|
|
|
|
this.get = function (templateId) {
|
2013-03-30 12:13:10 -07:00
|
|
|
|
|
2013-06-24 16:41:59 -07:00
|
|
|
|
var templateKey = templateId.toLowerCase();
|
2013-03-30 12:13:10 -07:00
|
|
|
|
|
2013-06-24 16:41:59 -07:00
|
|
|
|
var templateFunction = Templates[templateKey];
|
2013-02-14 19:10:03 -08:00
|
|
|
|
|
2013-06-24 16:41:59 -07:00
|
|
|
|
if (!templateFunction) {
|
|
|
|
|
throw 'couldn\'t find pre-compiled template ' + templateKey;
|
2013-06-14 22:28:35 -07:00
|
|
|
|
}
|
2013-06-24 16:41:59 -07:00
|
|
|
|
|
|
|
|
|
return function (data) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
return templateFunction(data);
|
|
|
|
|
}
|
|
|
|
|
catch (error) {
|
|
|
|
|
console.error('template render failed for ' + templateKey + ' ' + error);
|
|
|
|
|
console.error(data);
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
};
|
2013-06-14 22:28:35 -07:00
|
|
|
|
};
|
2013-06-14 16:18:37 -07:00
|
|
|
|
};
|
2013-06-24 16:41:59 -07:00
|
|
|
|
});
|
2013-06-14 22:28:35 -07:00
|
|
|
|
|
|
|
|
|
|