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