diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-04-04 10:46:11 -0700 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-04-04 10:46:11 -0700 |
commit | 0a6194340f56a3b640ee438972762fc72178c6ff (patch) | |
tree | 110553ebcdd240a90213a5c59405807479578d74 /lib/generate | |
parent | e0d96b316390660557c1eac72314cdd659ba58e0 (diff) | |
download | gitbook-0a6194340f56a3b640ee438972762fc72178c6ff.zip gitbook-0a6194340f56a3b640ee438972762fc72178c6ff.tar.gz gitbook-0a6194340f56a3b640ee438972762fc72178c6ff.tar.bz2 |
Remove file template.js
Diffstat (limited to 'lib/generate')
-rw-r--r-- | lib/generate/index.js | 1 | ||||
-rw-r--r-- | lib/generate/template.js | 66 |
2 files changed, 0 insertions, 67 deletions
diff --git a/lib/generate/index.js b/lib/generate/index.js index b6782f0..15b1bef 100644 --- a/lib/generate/index.js +++ b/lib/generate/index.js @@ -5,7 +5,6 @@ var path = require("path"); var fs = require("./fs"); var parse = require("../parse"); -var template = require("./template"); var generators = { "site": require("./generator_site"), 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 |