Fix context for template block/filters

This commit is contained in:
Samy Pessé
2016-03-18 11:14:04 +01:00
parent 82d8c3e2d9
commit d5a575c5e0
+11 -7
View File
@@ -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