2012-01-23 23:14:16 +01:00
|
|
|
#!/usr/bin/env node
|
|
|
|
var hogan = require('hogan.js')
|
|
|
|
, fs = require('fs')
|
|
|
|
|
|
|
|
var layout, pages
|
|
|
|
|
|
|
|
// compile layout template
|
|
|
|
layout = fs.readFileSync(__dirname + '/../templates/layout.mustache', 'utf-8')
|
2012-01-24 04:55:00 +01:00
|
|
|
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) {
|
|
|
|
|
|
|
|
var page = fs.readFileSync(__dirname + '/../templates/pages/' + name, 'utf-8')
|
|
|
|
, context = {}
|
|
|
|
|
|
|
|
context[name.replace(/\.mustache$/, '')] = 'active'
|
2012-01-24 04:55:00 +01:00
|
|
|
context._i = true
|
|
|
|
|
|
|
|
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')
|
|
|
|
})
|