summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/plugin.js5
-rw-r--r--lib/template.js12
2 files changed, 11 insertions, 6 deletions
diff --git a/lib/plugin.js b/lib/plugin.js
index fa38e20..79da7d7 100644
--- a/lib/plugin.js
+++ b/lib/plugin.js
@@ -115,7 +115,10 @@ Plugin.prototype.getFilters = function() {
return [
key,
function() {
- var ctx = this;
+ var ctx = {
+ ctx: this.ctx,
+ book: that.book
+ };
var args = Array.prototype.slice.apply(arguments);
var callback = _.last(args);
diff --git a/lib/template.js b/lib/template.js
index 69a1bd5..4b3fdbe 100644
--- a/lib/template.js
+++ b/lib/template.js
@@ -69,14 +69,16 @@ var TemplateEngine = function(book) {
// Add filter
-TemplateEngine.prototype.addFilter = function(key, filter) {
- if (this.env.getFilter(filterName)) {
+TemplateEngine.prototype.addFilter = function(filterName, func) {
+ try {
+ this.env.getFilter(filterName);
this.log.warn.ln("conflict in filters, '"+filterName+"' is already set");
return false;
+ } catch(e) {
+ this.log.debug.ln("add filter '"+filterName+"'");
+ this.env.addFilter(filterName, func, true);
+ return true;
}
- this.log.debug.ln("add filter '"+key+"'");
- this.env.addFilter(key, func, true);
- return true;
};
// Render a string from the book