summaryrefslogtreecommitdiffstats
path: root/lib/page
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-02-14 17:41:55 +0100
committerSamy Pessé <samypesse@gmail.com>2016-02-14 17:41:55 +0100
commit01a7c6f4e0e6518197b93ac350e73940197f22b4 (patch)
tree8d99c81177f00853d381e4b5cdec011ec1497be6 /lib/page
parent0e86cdeb4a3af445700e8e3ebbdb245e16581c17 (diff)
downloadgitbook-01a7c6f4e0e6518197b93ac350e73940197f22b4.zip
gitbook-01a7c6f4e0e6518197b93ac350e73940197f22b4.tar.gz
gitbook-01a7c6f4e0e6518197b93ac350e73940197f22b4.tar.bz2
Add help chapter about variables
Diffstat (limited to 'lib/page')
-rw-r--r--lib/page/index.js21
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/page/index.js b/lib/page/index.js
index 2a4553f..d057441 100644
--- a/lib/page/index.js
+++ b/lib/page/index.js
@@ -103,6 +103,20 @@ Page.prototype.read = function() {
.then(this.update);
};
+// Return templating context for this page
+// This is used both for themes and page parsing
+Page.prototype.getContext = function() {
+ return {
+ file: {
+ path: this.path,
+ mtime: this.mtime
+ },
+ page: {
+ // todo
+ }
+ };
+};
+
// Parse the page and return its content
Page.prototype.parse = function(output) {
var that = this;
@@ -119,12 +133,7 @@ Page.prototype.parse = function(output) {
// Render template
.then(function() {
- return that.book.template.renderString(that.content, {
- file: {
- path: that.path,
- mtime: that.mtime
- }
- }, {
+ return that.book.template.renderString(that.content, that.getContext(), {
file: that.path
})
.then(that.update);