summaryrefslogtreecommitdiffstats
path: root/lib/template
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-04-10 18:20:51 +0200
committerSamy Pessé <samypesse@gmail.com>2016-04-10 18:20:51 +0200
commitb1981e09b823a3a3f8632940f435958f3f3c5a56 (patch)
tree621c9d2bd7cc9548e7988f48a2b3eca9a08ee02c /lib/template
parentc9edd0a7958a49a00587f195d86492c177c3f6ae (diff)
downloadgitbook-b1981e09b823a3a3f8632940f435958f3f3c5a56.zip
gitbook-b1981e09b823a3a3f8632940f435958f3f3c5a56.tar.gz
gitbook-b1981e09b823a3a3f8632940f435958f3f3c5a56.tar.bz2
Fix generator deprecation warning being shown for each call
Diffstat (limited to 'lib/template')
-rw-r--r--lib/template/index.js16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/template/index.js b/lib/template/index.js
index 410c2f5..9a5d92f 100644
--- a/lib/template/index.js
+++ b/lib/template/index.js
@@ -63,6 +63,13 @@ function TemplateEngine(output) {
// Add default blocks and filters
this.addBlocks(defaultBlocks);
this.addFilters(defaultFilters);
+
+ // Build context for this book with depreacted fields
+ this.ctx = {
+ book: this.book,
+ output: this.output
+ };
+ error.deprecateField(this.ctx, 'generator', this.output.name, '"generator" property is deprecated, use "output.generator" instead');
}
// Bind a function to a context
@@ -71,12 +78,9 @@ TemplateEngine.prototype.bindContext = function(func) {
var that = this;
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');
+ var ctx = _.extend({
+ ctx: this.ctx
+ }, that.ctx);
return func.apply(ctx, arguments);
};