Open
Description
Essentially you could output HTML pages using a JSX-like syntax:
-- I can define whatever data I like in plain old Lua.
local articles = {
{
title = "I made JSX for Lua (because I hate static sites)",
description = "This site now runs on a custom dialect of Lua.",
slug = "luax",
date = os.time({ year = 2023, month = 12, day = 27 }),
},
-- more articles...
}
-- "Components" are just Lua functions that return HTML.
-- Lua expressions can be placed in attributes or text.
function Article(atts, children)
local a = atts.article
return <article>
<header>
<h1><a href={ absurl(a.slug) }>{{ a.title }}</a></h1>
<span class="post-details">
<time datetime={ os.date("%Y-%m-%dT%H:%M:%S%z", atts.date) } itemprop="datePublished">
{{ os.date("%B %-d, %Y", atts.date) }}
</time>
</span>
</header>
<p>
{{ a.description }}
</p>
</article>
end
-- I can use Lua's package system to organize my templates.
require("base")
-- Whatever the file returns will be rendered and sent to the browser.
return <Base>
<div class="list">
{{ map(articles, function (a)
<Article article={ a } />
end) }}
</div>
</Base>
I would vastly prefer this to any of the other template systems that exist. It does depend on LuaX getting extracted from the creator's personal project and made into a module that can be imported, which I have raised an issue on here: bvisness/bvisness.me#1