From 3bff1316d1fc22f81b542d614c4bc90953bfa322 Mon Sep 17 00:00:00 2001 From: frosty Date: Sat, 19 Sep 2026 22:24:20 -0400 Subject: feat: add html.element lua helper --- examples/site/build.lua | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'examples') diff --git a/examples/site/build.lua b/examples/site/build.lua index 0b9e67a..4d0939a 100644 --- a/examples/site/build.lua +++ b/examples/site/build.lua @@ -1,9 +1,5 @@ -- External scripts are resolved relative to the HTML file that includes them :) -local function element(tag, attributes, children) - return { tag = tag, attributes = attributes or {}, children = children or {} } -end - local function find_by_class(node, wanted) if type(node) ~= "table" then return nil end local classes = node.attributes and node.attributes.class or "" @@ -27,7 +23,7 @@ local features = { local feature_list = assert(find_by_class(page, "feature-list")) for _, feature in ipairs(features) do - table.insert(feature_list.children, element("li", {}, { feature })) + table.insert(feature_list.children, html.element("li", nil, { feature })) end local entries = {} @@ -41,8 +37,8 @@ summary.text = tostring(#entries) .. " entries" local file_list = assert(find_by_class(page, "file-list")) for _, entry in ipairs(entries) do - table.insert(file_list.children, element("li", {}, { - element("code", {}, { entry.path }), + table.insert(file_list.children, html.element("li", nil, { + html.element("code", nil, { entry.path }), " (", entry.type, ")" })) end @@ -54,7 +50,7 @@ local mixed = assert(find_by_class(page, "mixed-content")) mixed.children = { { kind = "comment", text = "generated by Lua" }, "Text with ", - element("strong", {}, { "an element" }), + html.element("strong", nil, { "an element" }), "." } -- cgit v1.3