2013-03-30 00:00:38 +01:00
|
|
|
|
"use strict";
|
2013-02-15 04:10:03 +01:00
|
|
|
|
|
2013-03-30 00:00:38 +01:00
|
|
|
|
Marionette.TemplateCache.get = function (templateId) {
|
2013-03-30 20:13:10 +01:00
|
|
|
|
|
|
|
|
|
var templateKey = templateId.toLowerCase();
|
|
|
|
|
|
2013-05-01 02:01:54 +02:00
|
|
|
|
var templateFunction = window.Templates[templateKey];
|
2013-02-15 04:10:03 +01:00
|
|
|
|
|
2013-03-30 00:00:38 +01:00
|
|
|
|
if (!templateFunction) {
|
2013-03-30 20:13:10 +01:00
|
|
|
|
throw 'couldn\'t find pre-compiled template ' + templateKey;
|
2013-02-15 04:10:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-03-30 00:00:38 +01:00
|
|
|
|
return function (data) {
|
2013-02-15 04:10:03 +01:00
|
|
|
|
|
2013-03-30 00:00:38 +01:00
|
|
|
|
try {
|
|
|
|
|
return templateFunction(data);
|
|
|
|
|
}
|
|
|
|
|
catch (error) {
|
2013-04-19 01:14:08 +02:00
|
|
|
|
console.error('template render failed for ' + templateKey + ' ' + error);
|
2013-03-30 00:00:38 +01:00
|
|
|
|
console.error(data);
|
2013-06-01 19:38:21 +02:00
|
|
|
|
throw error;
|
2013-03-30 00:00:38 +01:00
|
|
|
|
}
|
|
|
|
|
};
|
2013-06-01 19:38:21 +02:00
|
|
|
|
};
|