2 var hogan = require('hogan.js')
4 , prod = process.argv[2] == 'production'
9 // compile layout template
10 layout = fs.readFileSync(__dirname + '/../templates/layout.mustache', 'utf-8')
11 layout = hogan.compile(layout, { sectionTags: [{o:'_i', c:'i'}] })
14 pages = fs.readdirSync(__dirname + '/../templates/pages')
17 pages.forEach(function (name) {
19 if (!name.match(/\.mustache$/)) return
21 var page = fs.readFileSync(__dirname + '/../templates/pages/' + name, 'utf-8')
24 context[name.replace(/\.mustache$/, '')] = 'active'
26 context.production = prod
28 .replace(/\.mustache/, '')
30 .replace(/(.)/, function ($1) { return $1.toUpperCase() })
32 if (context.title == 'Index') {
35 context.title += ' ยท ' + title
38 page = hogan.compile(page, { sectionTags: [{o:'_i', c:'i'}] })
39 page = layout.render(context, {
43 fs.writeFileSync(__dirname + '/../' + name.replace(/mustache$/, 'html'), page, 'utf-8')