summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2018-09-10 08:51:51 -0400
committerPaul Duncan <pabs@pablotron.org>2018-09-10 08:51:51 -0400
commit983382978b724edae4984182242c88e3e723ae6c (patch)
tree3f52af3fcf54dbd7163d4b3efb09a8f83a8e887f
parent1aa02540223ebc5f358eae5f4425356109b8ba23 (diff)
downloadluigi-template-983382978b724edae4984182242c88e3e723ae6c.tar.bz2
luigi-template-983382978b724edae4984182242c88e3e723ae6c.zip
js: add Cache#get, more jsdoc updates
-rw-r--r--js/luigi-template.js34
1 files changed, 26 insertions, 8 deletions
diff --git a/js/luigi-template.js b/js/luigi-template.js
index 938cfaa..88652bd 100644
--- a/js/luigi-template.js
+++ b/js/luigi-template.js
@@ -149,6 +149,9 @@ var Luigi = (function() {
* @namespace Luigi
* @alias Luigi
* @global
+ *
+ * @property VERSION {string} Version of Luigi Template.
+ * @property FILTERS {string} Default filter set.
*/
var Luigi = {
/**
@@ -322,18 +325,16 @@ var Luigi = (function() {
};
/**
- * Find named template in cache and run it with the given arguments.
+ * Find named template in this cache or raise an Error.
*
- * @function Luigi.Cache#run
- * @alias Luigi.Cache#run
+ * @function Luigi.Cache#get
+ * @alias Luigi.Cache#get
*
* @param key {hash} Template key (required).
- * @param args {hash} Template run arguments (required).
- * @param fn {function} Callback function (optional).
*
- * @returns {string} Result of applying arguments to template.
+ * @returns {Template} Template matching given key.
*/
- Luigi.Cache.prototype.run = function(key, args, fn) {
+ Luigi.Cache.prototype.get = function(key, args, fn) {
if (!(key in this.cache)) {
var s = null;
@@ -352,7 +353,24 @@ var Luigi = (function() {
}
// run template
- return this.cache[key].run(args, fn);
+ return this.cache[key];
+ };
+
+ /**
+ * Find named template in cache and run it with the given arguments.
+ *
+ * @function Luigi.Cache#run
+ * @alias Luigi.Cache#run
+ *
+ * @param key {hash} Template key (required).
+ * @param args {hash} Template run arguments (required).
+ * @param fn {function} Callback function (optional).
+ *
+ * @returns {string} Result of applying arguments to template.
+ */
+ Luigi.Cache.prototype.run = function(key, args, fn) {
+ // get and run template
+ return this.get(key).run(args, fn);
};
/**