From b99de1d4e79e6c4a548d9dddca730eaeeb63a1c9 Mon Sep 17 00:00:00 2001 From: s-ol Date: Wed, 31 Oct 2018 19:52:16 +1100 Subject: almost there tbh --- render.moon | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'render.moon') 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 [ ] -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 " @@ -16,7 +31,9 @@ with io.open output_name, 'w' MMM: lunar low-gravity scripting playground - + + + @@ -24,7 +41,7 @@ with io.open output_name, 'w' - #{flush!} + #{content} " \close! -- cgit v1.2.3