diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2018-10-31 08:52:16 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2018-10-31 08:52:16 +0000 |
| commit | b99de1d4e79e6c4a548d9dddca730eaeeb63a1c9 (patch) | |
| tree | 1b34fd16a46d2567f7e767d9f260ad238bea0ef9 /render.moon | |
| parent | REHYDRATION (diff) | |
| download | mmm-b99de1d4e79e6c4a548d9dddca730eaeeb63a1c9.tar.gz mmm-b99de1d4e79e6c4a548d9dddca730eaeeb63a1c9.zip | |
almost there tbh
Diffstat (limited to 'render.moon')
| -rw-r--r-- | render.moon | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/render.moon b/render.moon index 7acf9a4..b144cce 100644 --- a/render.moon +++ b/render.moon @@ -1,12 +1,27 @@ package.moonpath = './?.server.moon;' .. package.moonpath import flush from require 'lib.init' +import render from require 'lib.mmmfs' -import indexed from require 'app' +-- usage: +-- moon render.moon <output> <fileder_path> [<prefix module> <prefix path>] -route_name = assert arg[1], "please specify the route name to build as an argument" -output_name = assert arg[2], "please specify the output filename as an argument" -route = assert indexed[route_name], "route not found: '#{route_name}'" -route\render! +{ output_name, path, prefix_mod, prefix_path } = arg +-- output_name = assert arg[1], "please specify the output filename as an argument" +-- path = assert arg[2], "please specify the path name to build as an argument" +assert output_name, "please specify the output filename as an argument" +assert path, "please specify the path name to build as an argument" + +root = if prefix_mod and prefix_path + -- prefix module and path are given, skip deeper into the tree + assert path\match '^' .. prefix_path + with require prefix_mod + \mount prefix_path, true +else + -- load full tree + with require 'root' + \mount! + +content = assert (render root, path), "no content" with io.open output_name, 'w' \write "<!DOCTYPE html> @@ -16,7 +31,9 @@ with io.open output_name, 'w' <title>MMM: lunar low-gravity scripting playground</title> <link rel=\"stylesheet\" type=\"text/css\" href=\"/main.css\" /> <link rel=\"preload\" as=\"fetch\" href=\"/lib/dom.lua\" /> - <link rel=\"preload\" as=\"fetch\" href=\"/lib/component.lua\" /> + <link rel=\"preload\" as=\"fetch\" href=\"/lib/mmmfs/init.lua\" /> + <link rel=\"preload\" as=\"fetch\" href=\"/lib/mmmfs/fileder.lua\" /> + <link rel=\"preload\" as=\"fetch\" href=\"/lib/mmmfs/browser.lua\" /> <script src=\"/fengari-web.js\"></script> <script src=\"/highlight.pack.js\"></script> <script src=\"//cdn.jsdelivr.net/npm/marked/marked.min.js\"></script> @@ -24,7 +41,7 @@ with io.open output_name, 'w' <body> <script type=\"application/lua\" src=\"/lib/init.lua\"></script> - #{flush!} + #{content} </body> </html>" \close! |
