Added "template" function for /app to async load of templates (html)
This commit is contained in:
parent
8967289631
commit
0eddaed6a1
|
@ -7,6 +7,21 @@ app.script = function(name, cback) {
|
|||
loadScript(name, file, cback);
|
||||
}
|
||||
|
||||
app.template = function(name, cback) {
|
||||
if (window.__cache_templates === undefined)
|
||||
window.__cache_templates = {};
|
||||
file = app.vars.js_dir + '/templates/' +
|
||||
name.replaceAll('.', '/') + '.html';
|
||||
name = 'template__'+name.replaceAll('.', '-');
|
||||
if (window.__cache_templates[name] !== undefined)
|
||||
return cback(window.__cache_templates[name]);
|
||||
http.get(file, {}, function(html) {
|
||||
html = html.trim();
|
||||
window.__cache_templates[name] = html;
|
||||
return cback(html);
|
||||
});
|
||||
}
|
||||
|
||||
function scriptPageHandler(modname, cfg) {
|
||||
cfg['callback'] = function(args) {
|
||||
app.script(modname, function(ok) {
|
||||
|
|
Loading…
Reference in New Issue