summaryrefslogtreecommitdiffstats
path: root/lib/template/index.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-03-18 11:14:04 +0100
committerSamy Pessé <samypesse@gmail.com>2016-03-18 11:14:04 +0100
commitd5a575c5e004d391909d00a292384a9c9e176361 (patch)
tree512f620b2f12427eb8c374baae1d821bc16e9733 /lib/template/index.js
parent82d8c3e2d954f06fb97644ae0934dbd4c3df8cb3 (diff)
downloadgitbook-d5a575c5e004d391909d00a292384a9c9e176361.zip
gitbook-d5a575c5e004d391909d00a292384a9c9e176361.tar.gz
gitbook-d5a575c5e004d391909d00a292384a9c9e176361.tar.bz2
Fix context for template block/filters
Diffstat (limited to 'lib/template/index.js')
-rw-r--r--lib/template/index.js18
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/template/index.js b/lib/template/index.js
index 5af2089..7be16b9 100644
--- a/lib/template/index.js
+++ b/lib/template/index.js
@@ -68,14 +68,18 @@ function TemplateEngine(output) {
// Bind a function to a context
// Filters and blocks are binded to this context
TemplateEngine.prototype.bindContext = function(func) {
- var ctx = {
- ctx: this.ctx,
- book: this.book,
- output: this.output
- };
- error.deprecateField(ctx, 'generator', this.output.name, '"generator" property is deprecated, use "output.generator" instead');
+ var that = this;
- return _.bind(func, ctx);
+ return function() {
+ var ctx = {
+ ctx: this.ctx,
+ book: that.book,
+ output: that.output
+ };
+ error.deprecateField(ctx, 'generator', that.output.name, '"generator" property is deprecated, use "output.generator" instead');
+
+ return func.apply(ctx, arguments);
+ };
};
// Interpolate a string content to replace shortcuts according to the filetype