Fixed an error message for NanoUI templates which fail to compile.

This commit is contained in:
Mark Aherne
2014-07-16 15:40:04 +01:00
parent 75e2a703b0
commit ce651b390c
+8 -3
View File
@@ -76,7 +76,7 @@ var NanoTemplate = function () {
_compiledTemplates[key] = doT.template(_templates[key], null, _templates)
}
catch (error) {
alert(error);
alert(error.message);
}
}
};
@@ -89,13 +89,18 @@ var NanoTemplate = function () {
_templates[key] = templateString;
},
parse: function (templateKey, data) {
if (!_compiledTemplates.hasOwnProperty(templateKey)) {
if (!_compiledTemplates.hasOwnProperty(templateKey) || !_compiledTemplates[templateKey]) {
if (!_templates.hasOwnProperty(templateKey)) {
alert('ERROR: Template "' + templateKey + '" does not exist in _compiledTemplates!');
return;
return '<h2>Template error (does not exist)</h2>';
}
compileTemplates();
}
if (typeof _compiledTemplates[templateKey] != 'function') {
alert(_compiledTemplates[templateKey]);
alert('ERROR: Template "' + templateKey + '" failed to compile!');
return '<h2>Template error (failed to compile)</h2>';
}
return _compiledTemplates[templateKey].call(this, data['data'], data['config'], _helpers);
},
addHelper: function (helperName, helperFunction) {