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();
|
|
|
|
|
|
|
|
|
|
var templateFunction = window.Templates[templateKey.toLowerCase()];
|
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 {
|
2013-03-30 19:13:10 +00:00
|
|
|
|
//console.log('rendering template ' + templateKey);
|
2013-03-29 23:00:38 +00:00
|
|
|
|
return templateFunction(data);
|
|
|
|
|
}
|
|
|
|
|
catch (error) {
|
2013-03-30 19:13:10 +00:00
|
|
|
|
console.error('template render failed for ' + templateKey + ' ' + error.message);
|
2013-03-29 23:00:38 +00:00
|
|
|
|
console.error(data);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
};
|