summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-02-21 19:41:38 +0100
committerSamy Pessé <samypesse@gmail.com>2016-02-21 19:41:38 +0100
commitd139d1d1bd65e3dd0eff2987f355bb16d8c24058 (patch)
tree619a68cf5f93a2a26502ce5f7347274e8b11fda0
parenta186544fadf040bc2b4c83dfe41b6bd2a482c5a1 (diff)
downloadgitbook-d139d1d1bd65e3dd0eff2987f355bb16d8c24058.zip
gitbook-d139d1d1bd65e3dd0eff2987f355bb16d8c24058.tar.gz
gitbook-d139d1d1bd65e3dd0eff2987f355bb16d8c24058.tar.bz2
Add "template.theme" and "template.default" variables
-rw-r--r--docs/_layouts/website/page.html14
-rw-r--r--lib/output/website.js14
2 files changed, 27 insertions, 1 deletions
diff --git a/docs/_layouts/website/page.html b/docs/_layouts/website/page.html
new file mode 100644
index 0000000..edce251
--- /dev/null
+++ b/docs/_layouts/website/page.html
@@ -0,0 +1,14 @@
+{% extends template.theme %}
+
+{% block page %}
+{{ super() }}
+<hr>
+<div class="btn-group btn-group-justified">
+ {% if page.previous and page.previous.path %}
+ <a class="btn" href="{{ page.previous.path|resolveFile }}"><b>Previous:</b> {{ page.previous.title }}</a>
+ {% endif %}
+ {% if page.next and page.next.path %}
+ <a class="btn" href="{{ page.next.path|resolveFile }}"><b>Next:</b> {{ page.next.title }}</a>
+ {% endif %}
+</div>
+{% endblock %}
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