diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-02-21 19:41:38 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-02-21 19:41:38 +0100 |
commit | d139d1d1bd65e3dd0eff2987f355bb16d8c24058 (patch) | |
tree | 619a68cf5f93a2a26502ce5f7347274e8b11fda0 /lib | |
parent | a186544fadf040bc2b4c83dfe41b6bd2a482c5a1 (diff) | |
download | gitbook-d139d1d1bd65e3dd0eff2987f355bb16d8c24058.zip gitbook-d139d1d1bd65e3dd0eff2987f355bb16d8c24058.tar.gz gitbook-d139d1d1bd65e3dd0eff2987f355bb16d8c24058.tar.bz2 |
Add "template.theme" and "template.default" variables
Diffstat (limited to 'lib')
-rw-r--r-- | lib/output/website.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/output/website.js b/lib/output/website.js index 835b8b5..929c82f 100644 --- a/lib/output/website.js +++ b/lib/output/website.js @@ -179,7 +179,19 @@ WebsiteOutput.prototype.onPage = function(page) { // Render a template using nunjucks // Templates are stored in `_layouts` folders WebsiteOutput.prototype.render = function(tpl, context) { - return Promise.nfcall(this.env.render.bind(this.env), this.templateName(tpl), context); + var filename = this.templateName(tpl); + + context = _.extend(context, { + template: { + // Same template but in the default theme + default: this.themeDefault? path.resolve(templatesPath(this.themeDefault.root), filename) : null, + + // Same template but in the theme + theme: path.resolve(templatesPath(this.theme.root), filename) + } + }); + + return Promise.nfcall(this.env.render.bind(this.env), filename, context); }; // Return a complete name for a template |