summaryrefslogtreecommitdiffstats
path: root/lib/generate/site/index.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2014-04-20 00:10:46 +0200
committerSamy Pessé <samypesse@gmail.com>2014-04-20 00:10:46 +0200
commit74d628676b3d5a49b0f461261ba39c6839557410 (patch)
treee22d2b7a6fc53235d4218e8ad3d3fb36f20ac09f /lib/generate/site/index.js
parent6fdd98ec3aa9158b74a5f80e1b35dec1604531d2 (diff)
downloadgitbook-74d628676b3d5a49b0f461261ba39c6839557410.zip
gitbook-74d628676b3d5a49b0f461261ba39c6839557410.tar.gz
gitbook-74d628676b3d5a49b0f461261ba39c6839557410.tar.bz2
Add option to change templates from plugin
Diffstat (limited to 'lib/generate/site/index.js')
-rw-r--r--lib/generate/site/index.js23
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js
index 9d738be..eaba6ee 100644
--- a/lib/generate/site/index.js
+++ b/lib/generate/site/index.js
@@ -30,13 +30,28 @@ var Generator = function() {
this.revision = Date.now();
this.indexer = indexer();
-
- // Load base template
- this.template = swig.compileFile(path.resolve(this.options.theme, 'templates/site.html'));
- this.langsTemplate = swig.compileFile(path.resolve(this.options.theme, 'templates/langs.html'));
};
util.inherits(Generator, BaseGenerator);
+// Load all templates
+Generator.prototype.loadTemplates = function() {
+ this.template = swig.compileFile(
+ this.plugins.template("site") || path.resolve(this.options.theme, 'templates/site.html')
+ );
+ this.langsTemplate = swig.compileFile(
+ this.plugins.template("langs") || path.resolve(this.options.theme, 'templates/langs.html')
+ );
+};
+
+// Load plugins
+Generator.prototype.loadPlugins = function() {
+ var that = this;
+
+ return BaseGenerator.prototype.loadPlugins.apply(this)
+ .then(function() {
+ return that.loadTemplates();
+ });
+};
// Generate a template
Generator.prototype._writeTemplate = function(tpl, options, output) {