<a href="<%url%>"><%label%></a>
<? if 1 > 2 then ?> <? else ?> <? end ?>
<ul> <? for i = 1, 9999 do ?> <li> №<%i%></li> <? end ?> </ul>
<html> <script><? require "scripts" ?></script> <style><? require "styles" ?></style> ...
<? function warn() ?> <b> !</b> <? end ?> ... <? warn() ?> ... <? --[[ ?> <? --]] ?>
(echo 'return function(_)_[=['; sed -e 's/[][]=[][]/]=]_"\0"_[=[/g; s/<%/]=]_(/g; s/%>/)_[=[/g; s/<[?]/]=] /g; s/[?]>/ _[=[/g'; echo ']=] end') < template.tpl > template.lua
function template.print(data, args, callback) local callback = callback or print local function exec(data) if type(data) == "function" then local args = args or {} setmetatable(args, { __index = _G }) setfenv(data, args) data(exec) else callback(tostring(data)) end end exec(data) end
luarocks install template
sudo apt-get install luarocks
Source: https://habr.com/ru/post/243321/