diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-01-23 17:40:53 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-01-23 17:40:53 +0100 |
commit | b88b4a0578c28af78a01a28591772f94d0dfe82e (patch) | |
tree | c832501d0396850e29aedd82b757b5634b435d52 /lib | |
parent | a964e197155e9ccdb17d3dab73d8857060d4ea65 (diff) | |
download | gitbook-b88b4a0578c28af78a01a28591772f94d0dfe82e.zip gitbook-b88b4a0578c28af78a01a28591772f94d0dfe82e.tar.gz gitbook-b88b4a0578c28af78a01a28591772f94d0dfe82e.tar.bz2 |
Add context configuration to Book object
Diffstat (limited to 'lib')
-rw-r--r-- | lib/book.js | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/book.js b/lib/book.js index 797783b..dcf0a33 100644 --- a/lib/book.js +++ b/lib/book.js @@ -16,7 +16,15 @@ var Plugin = require("./plugin"); var generators = require("./generators"); -var Book = function(root, options, parent) { +var Book = function(root, context, parent) { + this.context = _.defaults(context || {}, { + // Extend book configuration + config: {}, + + // Log function + log: console.log.bind(console) + }) + // Root folder of the book this.root = root; @@ -24,7 +32,7 @@ var Book = function(root, options, parent) { this.parent = parent; // Configuration - this.config = new Configuration(this, options); + this.config = new Configuration(this, this.context.config); Object.defineProperty(this, "options", { get: function () { return this.config.options; @@ -85,9 +93,11 @@ Book.prototype.parse = function() { that.books = _.map(that.langs, function(lang) { return new Book( path.join(that.root, lang.path), - _.extend({}, that.options, { - 'output': path.join(that.options.output, lang.path), - 'lang': lang.lang + _.merge({}, that.context, { + config: _.extend({}, that.options, { + 'output': path.join(that.options.output, lang.path), + 'lang': lang.lang + }) }), that ) |