mirror of https://github.com/Kozea/pygal.git
Python to generate nice looking SVG graph
http://pygal.org/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.2 KiB
44 lines
1.2 KiB
#!/usr/bin/env node |
|
var hogan = require('hogan.js') |
|
, fs = require('fs') |
|
, prod = process.argv[2] == 'production' |
|
, title = 'Twitter Bootstrap' |
|
|
|
var layout, pages |
|
|
|
// compile layout template |
|
layout = fs.readFileSync(__dirname + '/../templates/layout.mustache', 'utf-8') |
|
layout = hogan.compile(layout, { sectionTags: [{o:'_i', c:'i'}] }) |
|
|
|
// retrieve pages |
|
pages = fs.readdirSync(__dirname + '/../templates/pages') |
|
|
|
// iterate over pages |
|
pages.forEach(function (name) { |
|
|
|
if (!name.match(/\.mustache$/)) return |
|
|
|
var page = fs.readFileSync(__dirname + '/../templates/pages/' + name, 'utf-8') |
|
, context = {} |
|
|
|
context[name.replace(/\.mustache$/, '')] = 'active' |
|
context._i = true |
|
context.production = prod |
|
context.title = name |
|
.replace(/\.mustache/, '') |
|
.replace(/\-.*/, '') |
|
.replace(/(.)/, function ($1) { return $1.toUpperCase() }) |
|
|
|
if (context.title == 'Index') { |
|
context.title = title |
|
} else { |
|
context.title += ' ยท ' + title |
|
} |
|
|
|
page = hogan.compile(page, { sectionTags: [{o:'_i', c:'i'}] }) |
|
page = layout.render(context, { |
|
body: page |
|
}) |
|
|
|
fs.writeFileSync(__dirname + '/../' + name.replace(/mustache$/, 'html'), page, 'utf-8') |
|
}) |