From 983382978b724edae4984182242c88e3e723ae6c Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Mon, 10 Sep 2018 08:51:51 -0400 Subject: js: add Cache#get, more jsdoc updates --- js/luigi-template.js | 34 ++++++++++++++++++++++++++-------- 1 file 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); }; /** -- cgit v1.2.3