diff options
Diffstat (limited to 'lib/page/index.js')
-rw-r--r-- | lib/page/index.js | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/lib/page/index.js b/lib/page/index.js index 6c63489..0377f35 100644 --- a/lib/page/index.js +++ b/lib/page/index.js @@ -116,30 +116,27 @@ Page.prototype.getContext = function() { if (dir == 'neutral') dir = null; } - return _.extend( - { - file: { - path: this.path, - mtime: this.mtime, - type: this.type - }, - page: _.extend({}, this.attributes, { - title: article? article.title : null, - next: next? next.getContext() : null, - previous: prev? prev.getContext() : null, - level: article? article.level : null, - depth: article? article.depth : 0, - content: this.content, - dir: dir - }) + return { + file: { + path: this.path, + mtime: this.mtime, + type: this.type }, - gitbook.getContext(), - this.book.getContext(), - this.book.langs.getContext(), - this.book.summary.getContext(), - this.book.glossary.getContext(), - this.book.config.getContext() - ); + page: _.extend({}, this.attributes, { + title: article? article.title : null, + next: next? next.getContext() : null, + previous: prev? prev.getContext() : null, + level: article? article.level : null, + depth: article? article.depth() : 0, + content: this.content, + dir: dir + }) + }; +}; + +// Return complete context for templating (page + book + summary + ...) +Page.prototype.getOutputContext = function(output) { + return _.extend({}, this.getContext(), output.getContext()); }; // Parse the page and return its content @@ -184,7 +181,7 @@ Page.prototype.toHTML = function(output) { // Render template .then(function() { - return output.template.render(that.content, that.getContext(), { + return output.template.render(that.content, that.getOutputContext(output), { path: that.path }) .then(that.update); |