hem-render-html
Version:
This module adds the ability to dynamically generate HTML files for your hem project.
49 lines (38 loc) • 1.1 kB
text/coffeescript
Hem = require('hem')
fs = require('fs')
html = require('./html')
path = require('path')
class HemRenderHtml extends Hem
htmlOptions:
html: './html'
htmlDelete: on
htmlGlobalContextFile: '__global.coffee'
htmlPath: './public'
constructor: (options = {}) ->
[key] = value for key, value of options
super
server: ->
super
build: ->
super
buildHtml: ->
if path.existsSync(.html)
.compile()
watch: ->
super
watchHtml: ->
dir = path.dirname(.html)
dir = .html
if path.existsSync(dir)
require('watch').watchTree dir, (file, curr, prev) =>
if curr and (curr.nlink is 0 or +curr.mtime isnt +prev?.mtime)
console.log "#{file} changed. Rebuilding all HTML files."
htmlPackage: ->
html.createPackage(.html, .htmlPath, .htmlDelete,
.htmlGlobalContextFile)
module.exports = HemRenderHtml