topical media & game development

talk show tell print

mobile-query-three-www-vendor-bootstrap-docs-build-index.js / js



  #!/usr/bin/env node
  var hogan = require('hogan.js')
    , fs    = require('fs')
    , prod  = process.argv[2] == 'production'
  
  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
  
    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')
  })


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.