diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-02-24 13:52:15 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-02-24 13:52:15 +0100 |
commit | 1ed63ce4f52aacac7134d6f6cff9773bec73fb18 (patch) | |
tree | e838249f6719685e70da34f917b0158fa1cbbe42 /lib | |
parent | e85ad95bcf3627a223b3a2eacaa29835142249eb (diff) | |
download | gitbook-1ed63ce4f52aacac7134d6f6cff9773bec73fb18.zip gitbook-1ed63ce4f52aacac7134d6f6cff9773bec73fb18.tar.gz gitbook-1ed63ce4f52aacac7134d6f6cff9773bec73fb18.tar.bz2 |
Add context for multi-lingual books
Diffstat (limited to 'lib')
-rw-r--r-- | lib/backbone/langs.js | 16 | ||||
-rw-r--r-- | lib/output/base.js | 1 | ||||
-rw-r--r-- | lib/page/index.js | 1 |
3 files changed, 18 insertions, 0 deletions
diff --git a/lib/backbone/langs.js b/lib/backbone/langs.js index a40bd80..e339fa9 100644 --- a/lib/backbone/langs.js +++ b/lib/backbone/langs.js @@ -62,4 +62,20 @@ Langs.prototype.count = function() { return _.size(this.languages); }; +// Return templating context for the languages list +Langs.prototype.getContext = function() { + if (this.count() == 0) return {}; + + return { + languages: { + list: _.map(this.languages, function(lang) { + return { + id: lang.id, + title: lang.title + }; + }) + } + }; +}; + module.exports = Langs; diff --git a/lib/output/base.js b/lib/output/base.js index 77c2d9f..fb0adca 100644 --- a/lib/output/base.js +++ b/lib/output/base.js @@ -202,6 +202,7 @@ Output.prototype.getContext = function() { return _.extend( {}, this.book.getContext(), + this.book.langs.getContext(), this.book.summary.getContext(), this.book.glossary.getContext(), this.book.config.getContext() diff --git a/lib/page/index.js b/lib/page/index.js index 45b3598..b512ff4 100644 --- a/lib/page/index.js +++ b/lib/page/index.js @@ -128,6 +128,7 @@ Page.prototype.getContext = function() { }, gitbook.getContext(), this.book.getContext(), + this.book.langs.getContext(), this.book.summary.getContext(), this.book.glossary.getContext(), this.book.config.getContext() |