aboutsummaryrefslogtreecommitdiffstats
path: root/build/render_all.moon
blob: b09957eb78478958ff3ed5c931bc756c98525825 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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!