From c78c54225cc5e51482dfa2d6960372c6aff67ea6 Mon Sep 17 00:00:00 2001 From: "pabs@pablotron.org" Date: Thu, 18 Dec 2014 23:13:44 -0500 Subject: add support for custom filter ovveride to js implementation --- js/luigi-template.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/js/luigi-template.js b/js/luigi-template.js index 925b811..5018b7b 100644 --- a/js/luigi-template.js +++ b/js/luigi-template.js @@ -238,8 +238,9 @@ LuigiTemplate = (function() { return r; } - function init(s) { + function init(s, filters) { this.s = s; + this.filters = filters || FILTERS; this.actions = parse_template(s); }; @@ -257,7 +258,7 @@ LuigiTemplate = (function() { throw new Error('missing key: ' + row.key) return reduce(row.filters, function(r, f) { - return FILTERS[f.name](r, f.args, o, this); + return this.filters[f.name](r, f.args, o, this); }, o[row.key]); } else { /* never reached */ @@ -334,8 +335,8 @@ LuigiTemplate = (function() { T.VERSION = VERSION; // add singleton run - T.run = function(s, o) { - return new T(s).run(o); + T.run = function(s, o, f) { + return new T(s, f).run(o); } // expose interface -- cgit v1.2.3