2013-06-22 06:24:24 +00:00
|
|
|
|
'use strict';
|
2013-02-15 03:10:03 +00:00
|
|
|
|
|
2013-06-15 05:28:35 +00:00
|
|
|
|
define(['templates'], function (Templates) {
|
|
|
|
|
return function () {
|
|
|
|
|
this.get = function (templateId) {
|
2013-03-30 19:13:10 +00:00
|
|
|
|
|
2013-06-15 05:28:35 +00:00
|
|
|
|
var templateKey = templateId.toLowerCase();
|
2013-03-30 19:13:10 +00:00
|
|
|
|
|
2013-06-15 05:28:35 +00:00
|
|
|
|
var templateFunction = Templates[templateKey];
|
2013-02-15 03:10:03 +00:00
|
|
|
|
|
2013-06-15 05:28:35 +00:00
|
|
|
|
if (!templateFunction) {
|
|
|
|
|
throw 'couldn\'t find pre-compiled template ' + templateKey;
|
|
|
|
|
}
|
2013-02-15 03:10:03 +00:00
|
|
|
|
|
2013-06-15 05:28:35 +00:00
|
|
|
|
return function (data) {
|
2013-02-15 03:10:03 +00:00
|
|
|
|
|
2013-06-15 05:28:35 +00:00
|
|
|
|
try {
|
|
|
|
|
return templateFunction(data);
|
|
|
|
|
}
|
|
|
|
|
catch (error) {
|
|
|
|
|
console.error('template render failed for ' + templateKey + ' ' + error);
|
|
|
|
|
console.error(data);
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
};
|
2013-06-14 23:18:37 +00:00
|
|
|
|
};
|
2013-03-29 23:00:38 +00:00
|
|
|
|
};
|
2013-06-14 23:18:37 +00:00
|
|
|
|
});
|
2013-06-15 05:28:35 +00:00
|
|
|
|
|
|
|
|
|
|