summaryrefslogtreecommitdiffstats
path: root/lib/generate/site/index.js
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@gmail.com>2014-10-15 21:29:23 +0200
committerAaron O'Mullan <aaron.omullan@gmail.com>2014-10-15 21:29:23 +0200
commitce50b893e926fed8905419efc8bce4a64ab2d5dc (patch)
tree83cf19e47f26fd77072ac63aeaf2152a4b30ffa6 /lib/generate/site/index.js
parent49e3bbc3d6e9e128df721494e9a10eaf15b7ddc8 (diff)
parent225ff27dd15b904d6a4a784c219522a28f316a5b (diff)
downloadgitbook-ce50b893e926fed8905419efc8bce4a64ab2d5dc.zip
gitbook-ce50b893e926fed8905419efc8bce4a64ab2d5dc.tar.gz
gitbook-ce50b893e926fed8905419efc8bce4a64ab2d5dc.tar.bz2
Merge pull request #482 from GitbookIO/feature/includes
Add include support, with variables and the whole shebang
Diffstat (limited to 'lib/generate/site/index.js')
-rw-r--r--lib/generate/site/index.js35
1 files changed, 18 insertions, 17 deletions
diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js
index a694f39..4179917 100644
--- a/lib/generate/site/index.js
+++ b/lib/generate/site/index.js
@@ -23,6 +23,16 @@ var Generator = function() {
};
util.inherits(Generator, BaseGenerator);
+// Add template loading to load
+Generator.prototype.load = function() {
+ var that = this;
+
+ return BaseGenerator.prototype.load.apply(this)
+ .then(function() {
+ return that.loadTemplates();
+ });
+};
+
// Load all templates
Generator.prototype.loadTemplates = function() {
this.template = swig.compileFile(
@@ -36,16 +46,6 @@ Generator.prototype.loadTemplates = function() {
);
};
-// 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, interpolate) {
var that = this;
@@ -118,16 +118,17 @@ Generator.prototype.prepareFile = function(content, _input) {
return _callHook("page:before");
})
.then(function() {
- // Lex page
- return parse.lex(page.content);
- })
- .then(function(lexed) {
- page.lexed = lexed;
-
+ // Lex, parse includes and get
// Get HTML generated sections
- return parse.page(lexed, {
+ return parse.page(page.content, {
+ // Local files path
dir: path.dirname(_input) || '/',
+ // Project's include folder
+ includes_dir: path.join(that.options.input, '_includes'),
+ // Output directory
outdir: path.dirname(_input) || '/',
+ // Templating variables
+ variables: that.variables,
});
})
.then(function(sections) {