0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-12-10 22:24:19 +01:00
Bootstrap/docs/build/index.js

33 lines
907 B
JavaScript
Raw Normal View History

2012-01-23 23:14:16 +01:00
#!/usr/bin/env node
var hogan = require('hogan.js')
, fs = require('fs')
2012-02-02 01:38:58 +01:00
, prod = process.argv[2] == 'production'
2012-01-23 23:14:16 +01:00
var layout, pages
// compile layout template
layout = fs.readFileSync(__dirname + '/../templates/layout.mustache', 'utf-8')
layout = hogan.compile(layout, { sectionTags: [{o:'_i', c:'i'}] })
2012-01-23 23:14:16 +01:00
// retrieve pages
pages = fs.readdirSync(__dirname + '/../templates/pages')
// iterate over pages
pages.forEach(function (name) {
2012-01-27 23:44:05 +01:00
if (!name.match(/\.mustache$/)) return
2012-01-27 23:43:41 +01:00
2012-01-23 23:14:16 +01:00
var page = fs.readFileSync(__dirname + '/../templates/pages/' + name, 'utf-8')
, context = {}
context[name.replace(/\.mustache$/, '')] = 'active'
context._i = true
2012-02-02 01:38:58 +01:00
context.production = prod
page = hogan.compile(page, { sectionTags: [{o:'_i', c:'i'}] })
2012-01-23 23:14:16 +01:00
page = layout.render(context, {
body: page
})
fs.writeFileSync(__dirname + '/../' + name.replace(/mustache$/, 'html'), page, 'utf-8')
})