summaryrefslogtreecommitdiff
path: root/js/luigi-template.js
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2018-09-09 03:59:46 -0400
committerPaul Duncan <pabs@pablotron.org>2018-09-09 03:59:46 -0400
commit7c2a6f215734d29f3be8c0a0c85307e896f48155 (patch)
tree5e65cafa8c73a4ebb1b4fa6f5a4f048b4ca9752c /js/luigi-template.js
parentfd0050d21c132f1c6cc2673ce1cc964d448b70c3 (diff)
downloadluigi-template-7c2a6f215734d29f3be8c0a0c85307e896f48155.tar.bz2
luigi-template-7c2a6f215734d29f3be8c0a0c85307e896f48155.zip
js: add cache singleton, support non-array cache templates
Diffstat (limited to 'js/luigi-template.js')
-rw-r--r--js/luigi-template.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/js/luigi-template.js b/js/luigi-template.js
index d48d668..473938f 100644
--- a/js/luigi-template.js
+++ b/js/luigi-template.js
@@ -300,8 +300,8 @@ LuigiTemplate = (function() {
var s = null;
if (key in this.templates) {
- // get template from constructor templates
- s = this.templates[key].join('');
+ s = this.templates[key];
+ s = (s.constructor === Array) ? s.join('') : s;
} else if (this.try_dom) {
// get source from inline script tag
s = get_inline_template(key);
@@ -317,6 +317,10 @@ LuigiTemplate = (function() {
return this.cache[key].run(args);
};
+ T.cache = function(args) {
+ return new T.Cache(args);
+ }
+
// declare domcache constructor
T.DOMCache = function() {
this.cache = {};