summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-02-24 16:53:33 +0100
committerSamy Pessé <samypesse@gmail.com>2016-02-24 16:53:33 +0100
commit40cc20e06e64a52ded4bd36ae4023000c9df2855 (patch)
tree77b928b8ac62410d8249ed30a9a6abd26ec6b2f5
parentc223f970ecd6c4a12d204e2223a81caf36dae4f6 (diff)
downloadgitbook-40cc20e06e64a52ded4bd36ae4023000c9df2855.zip
gitbook-40cc20e06e64a52ded4bd36ae4023000c9df2855.tar.gz
gitbook-40cc20e06e64a52ded4bd36ae4023000c9df2855.tar.bz2
Load plugins once
-rw-r--r--lib/output/base.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/output/base.js b/lib/output/base.js
index fb0adca..e0b58b4 100644
--- a/lib/output/base.js
+++ b/lib/output/base.js
@@ -15,8 +15,9 @@ to output "something".
The process is mostly on the behavior of "onPage" and "onAsset"
*/
-function Output(book, opts) {
+function Output(book, opts, parent) {
_.bindAll(this);
+ this.parent = parent;
this.opts = _.defaults(opts || {}, {
directoryIndex: true
@@ -26,7 +27,11 @@ function Output(book, opts) {
this.log = this.book.log;
// Create plugins manager
- this.plugins = new PluginsManager(this.book);
+ if (this.parent) {
+ this.plugins = this.parent.plugins;
+ } else {
+ this.plugins = new PluginsManager(this.book);
+ }
// Create template engine
this.template = new TemplateEngine(this);
@@ -47,7 +52,7 @@ Output.prototype.generate = function() {
// Load all plugins
.then(function() {
- return that.plugins.loadAll()
+ return Promise(that.parent? null: that.plugins.loadAll())
.then(function() {
that.template.addFilters(that.plugins.getFilters());
that.template.addBlocks(that.plugins.getBlocks());
@@ -191,7 +196,7 @@ Output.prototype.onResolveTemplate = function(from, to) {
// Prepare output for a language book
Output.prototype.onLanguageBook = function(book) {
- return new this.constructor(book, this.opts);
+ return new this.constructor(book, this.opts, this);
};