git.s-ol.nu mmm / 9632233 build / render_all.moon
9632233

Tree @9632233 (Download .tar.gz)

render_all.moon @9632233raw · history · blame

add = (tmpl) ->
  package.path ..= ";#{tmpl}.lua"
  package.moonpath ..= ";#{tmpl}.moon"

add '?'
add '?.server'
add '?/init'
add '?/init.server'

require 'mmm'
import Fileder from require 'mmm.mmmfs.fileder'
import get_store from require 'mmm.mmmfs.stores'
import render from require 'mmm.mmmfs.layout'

-- usage:
-- moon render_all.moon [STORE] [startpath]
{ store, startpath } = arg

export STATIC
STATIC = true

store = get_store store
tree = Fileder store
tree = tree\walk startpath if startpath

for fileder in coroutine.wrap tree\iterate
  print "rendering '#{fileder.path}'..."
  os.execute "mkdir -p 'out/#{fileder.path}'"

  with io.open "out/#{fileder.path}/index.html", 'w'
    \write render (fileder\get 'text/html'), fileder
    \close!