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