A tool to compile lsp (asp/jsp/ejs like html template) to lua code
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.chs.md
README.md
lsp.lua
lspc.lua
test.lua
utils.lua

README.md

Lua Server Page Compiler is a tool to compiler lsp (asp/jsp/ejs like html template) to lua code which will generate html.

It's written by Lua. Support layout and partial view. But don't have http handler or http server module.

It's tested by Lua 5.2.

There's a example below.

The layout.lsp file:

<html>
<head>
<title><%= title %></title>
</head>
<body>
<%- body %>
</body>
</html>

the body.lsp file:

<%
hello = "this is a test"
%>

<p><%= hello %></p>

<ul>
<%- partial("partial.lsp") %>
</ul>

the partial.lsp file:

<li><%= _item %></li>

and then run the command:

lua lspc.lua body.lsp layout.lsp "title=\"aaa\" _list={\"bb\", \"cc\"}" > test.lua

then run test.lua will generate the html:

<html>
<head>
<title>test</title>
</head>
<body>

<p>this is a test</p>

<ul>
<li>abc</li>
<li>xyz</li>
</ul>
</body>
</html>

PS: run following command will generate html directly:

lua lspc.lua body.lsp layout.lsp "title=\"aaa\" _list={\"bb\", \"cc\"}" | lua -