summaryrefslogtreecommitdiff
path: root/marigold.lua
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-05-22 12:57:34 -0500
committersanine <sanine.not@pm.me>2022-05-22 12:57:34 -0500
commit7188614f0e2103f2cfc87dd0cb268f82fafd8c22 (patch)
tree3ad696c8a08bb229f219540de849f69f2dc5346e /marigold.lua
parent825194d0e5a1c16d3c3170a90a9a2679146044a7 (diff)
allow setting attributes
Diffstat (limited to 'marigold.lua')
-rw-r--r--marigold.lua8
1 files changed, 8 insertions, 0 deletions
diff --git a/marigold.lua b/marigold.lua
index 16aa054..4f04052 100644
--- a/marigold.lua
+++ b/marigold.lua
@@ -68,7 +68,15 @@ marigold.h = function(tag_type, content, tbl)
tag.content = content
tag.attributes = {}
tag.children = {}
+
if tbl then
+ -- add attributes
+ for k, v in pairs(tbl) do
+ if type(k) == 'string' then
+ tag.attributes[k] = v
+ end
+ end
+ -- add children
for _, child in ipairs(tbl) do
table.insert(tag.children, child)
end