diff options
Diffstat (limited to 'lib/template.js')
-rw-r--r-- | lib/template.js | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/template.js b/lib/template.js index 32c46de..69a1bd5 100644 --- a/lib/template.js +++ b/lib/template.js @@ -45,6 +45,7 @@ var BookLoader = nunjucks.Loader.extend({ var TemplateEngine = function(book) { this.book = book; + this.log = this.book.log; // Nunjucks env this.env = new nunjucks.Environment( @@ -66,12 +67,16 @@ var TemplateEngine = function(book) { ); }; -// Add filters -TemplateEngine.prototype.addFilters = function(filters) { - _.each(filters, function(func, key) { - this.book.log.debug.ln("add filter '"+key+"'"); - this.env.addFilter(key, func); - }, this); + +// Add filter +TemplateEngine.prototype.addFilter = function(key, filter) { + if (this.env.getFilter(filterName)) { + this.log.warn.ln("conflict in filters, '"+filterName+"' is already set"); + return false; + } + this.log.debug.ln("add filter '"+key+"'"); + this.env.addFilter(key, func, true); + return true; }; // Render a string from the book |