summaryrefslogtreecommitdiff
path: root/marigold.lua
diff options
context:
space:
mode:
Diffstat (limited to 'marigold.lua')
-rw-r--r--marigold.lua27
1 files changed, 26 insertions, 1 deletions
diff --git a/marigold.lua b/marigold.lua
index 4f04052..37cbdfb 100644
--- a/marigold.lua
+++ b/marigold.lua
@@ -1,6 +1,6 @@
-- ANTI-CAPITALIST SOFTWARE LICENSE (v 1.4)
--
--- Copyright (c) 2022 Kate Swanson
+-- marigold-cgi Copyright (c) 2022 Kate Swanson
--
-- This is anti-capitalist software, released for free use by individuals and
-- organizations that do not operate by capitalist principles.
@@ -84,4 +84,29 @@ marigold.h = function(tag_type, content, tbl)
return tag
end
+
+marigold.html = function(tbl, indent_level)
+ indent_level = indent_level or 0
+
+ -- generate attribute strings
+ local attributes = {}
+ for k, v in pairs(tbl.attributes) do
+ table.insert(attributes, string.format(' %s="%s"', k, v))
+ end
+ if test then
+ -- sort alphabetically for well-defined testing
+ table.sort(attributes)
+ end
+ local a = ''
+ for _, attrib in ipairs(attributes) do
+ a = a .. attrib
+ end
+
+ local open = string.format('<%s%s>', tbl.tag, a)
+ local close = string.format('</%s>', tbl.tag)
+
+ return string.format('%s%s%s', open, tbl.content, close)
+end
+
+
return marigold