summaryrefslogtreecommitdiffstats
path: root/lib/backbone
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-02-24 13:52:15 +0100
committerSamy Pessé <samypesse@gmail.com>2016-02-24 13:52:15 +0100
commit1ed63ce4f52aacac7134d6f6cff9773bec73fb18 (patch)
treee838249f6719685e70da34f917b0158fa1cbbe42 /lib/backbone
parente85ad95bcf3627a223b3a2eacaa29835142249eb (diff)
downloadgitbook-1ed63ce4f52aacac7134d6f6cff9773bec73fb18.zip
gitbook-1ed63ce4f52aacac7134d6f6cff9773bec73fb18.tar.gz
gitbook-1ed63ce4f52aacac7134d6f6cff9773bec73fb18.tar.bz2
Add context for multi-lingual books
Diffstat (limited to 'lib/backbone')
-rw-r--r--lib/backbone/langs.js16
1 files changed, 16 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;