diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-04-14 14:51:42 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-04-14 14:51:42 +0200 |
commit | 114c4abcd1a751feaa96ebecdf814bb42ac1a44a (patch) | |
tree | c79568be69f50c2270577923e1232f02b03d4fbc | |
parent | e1e3d11932907f9568b30c9c185fdc4000d3e6c4 (diff) | |
download | gitbook-114c4abcd1a751feaa96ebecdf814bb42ac1a44a.zip gitbook-114c4abcd1a751feaa96ebecdf814bb42ac1a44a.tar.gz gitbook-114c4abcd1a751feaa96ebecdf814bb42ac1a44a.tar.bz2 |
Add method for theme: template.getJSContext
-rw-r--r-- | lib/output/website.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/output/website.js b/lib/output/website.js index 3cf890e..1eaf98a 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: { |