From 114c4abcd1a751feaa96ebecdf814bb42ac1a44a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Thu, 14 Apr 2016 14:51:42 +0200 Subject: [PATCH] Add method for theme: template.getJSContext --- lib/output/website.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/output/website.js b/lib/output/website.js index 3cf890e79..1eaf98a58 100644 --- a/lib/output/website.js +++ b/lib/output/website.js @@ -216,11 +216,24 @@ WebsiteOutput.prototype.outputMultilingualIndex = function() { // Render a template using nunjucks // Templates are stored in `_layouts` folders WebsiteOutput.prototype.render = function(tpl, context) { + var that = this; var filename = this.templateName(tpl); context = _.extend(context, { template: { - self: filename + self: filename, + getJSContext: function() { + return { + page: _.omit(context.page, 'content'), + config: context.config, + file: context.file, + gitbook: context.gitbook, + basePath: location.normalize(that.resolveForPage(context.file.path, './')), + book: { + language: context.book.language + } + }; + } }, plugins: {