summaryrefslogtreecommitdiffstats
path: root/lib/generate/template.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/generate/template.js')
-rw-r--r--lib/generate/template.js66
1 files changed, 0 insertions, 66 deletions
diff --git a/lib/generate/template.js b/lib/generate/template.js
deleted file mode 100644
index d4e8cae..0000000
--- a/lib/generate/template.js
+++ /dev/null
@@ -1,66 +0,0 @@
-var swig = require('swig');
-var path = require('path');
-var _ = require("lodash");
-
-var parse = require("../parse");
-
-var fs = require('./fs');
-
-swig.setFilter('lines', function(content) {
- return content.split('\n').length;
-});
-
-// return a templeter for page
-var initTemplate = function(options) {
- var tpl = swig.compileFile(path.resolve(__dirname, '../../templates/page.html'));
-
- options = _.defaults(options || {}, {
- // Base folder for input
- root: "./",
-
- // Base folder for output
- output: "./",
-
- // Locals for templates
- locals: {}
- });
-
- return function(input, output, local) {
- var _input = input, _output = output;
- input = path.join(options.root, input);
- output = path.join(options.output, output);
-
- var basePath = path.relative(path.dirname(output), options.output) || ".";
-
- // Read markdown file
- return fs.readFile(input, "utf-8")
-
- // Parse sections
- .then(function(markdown) {
- return parse.page(markdown, {
- repo: options.locals.githubId,
- dir: path.dirname(_input) || '/'
- });
- })
-
- //Calcul template
- .then(function(sections) {
- return tpl(
- _.extend(local || {}, options.locals, {
- _input: _input,
- content: sections,
- basePath: basePath,
- staticBase: path.join(basePath, "gitbook"),
- progress: parse.progress(options.locals.allNavigation, _output)
- })
- );
- })
-
- // Write html
- .then(function(html) {
- return fs.writeFile(output, html);
- })
- }
-};
-
-module.exports = initTemplate; \ No newline at end of file