|
|
|
@ -3,6 +3,7 @@
|
|
|
|
|
var config = {},
|
|
|
|
|
templates,
|
|
|
|
|
fs = null,
|
|
|
|
|
path = null,
|
|
|
|
|
available_templates = [],
|
|
|
|
|
parsed_variables = {},
|
|
|
|
|
apiXHR;
|
|
|
|
@ -12,7 +13,8 @@
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
fs = require('fs');
|
|
|
|
|
fs = require('fs'),
|
|
|
|
|
path = require('path');
|
|
|
|
|
} catch (e) {}
|
|
|
|
|
|
|
|
|
|
templates.force_refresh = function (tpl) {
|
|
|
|
@ -127,6 +129,27 @@
|
|
|
|
|
loadTemplates(templates_to_load || [], custom_templates || false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
templates.render = function(filename, options, fn) {
|
|
|
|
|
if ('function' === typeof options) {
|
|
|
|
|
fn = options, options = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var tpl = filename
|
|
|
|
|
.replace(path.join(__dirname + '/../templates/'), '')
|
|
|
|
|
.replace('.' + options.settings['view engine'], '');
|
|
|
|
|
|
|
|
|
|
if (!templates[tpl]) {
|
|
|
|
|
fs.readFile(filename, function (err, html) {
|
|
|
|
|
templates[tpl] = html.toString();
|
|
|
|
|
templates.prepare(templates[tpl]);
|
|
|
|
|
|
|
|
|
|
return fn(err, templates[tpl].parse(options));
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
return fn(null, templates[tpl].parse(options));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
templates.getTemplateNameFromUrl = function (url) {
|
|
|
|
|
var parts = url.split('?')[0].split('/');
|
|
|
|
|
|
|
|
|
@ -419,6 +442,8 @@
|
|
|
|
|
})(data, "", template);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports.__express = module.exports.render;
|
|
|
|
|
|
|
|
|
|
if ('undefined' !== typeof window) {
|
|
|
|
|
window.templates = module.exports;
|
|
|
|
|
templates.init();
|
|
|
|
|