summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsko Nõmm <asko@nmm.ee>2025-09-21 23:19:24 +0300
committerAsko Nõmm <asko@nmm.ee>2025-09-21 23:19:24 +0300
commit42d7a2063b9a923b6538bee9c61eda04f1242d85 (patch)
tree482beeaad51f66d2938a83e767c26c69d6a03529
parent5f163f2b62613368714d8a1e8b342daaac0f89d5 (diff)
Starting work on HTML builder functions. Probably needs a different namespace.
-rw-r--r--src/dompa/utils.cljc35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/dompa/utils.cljc b/src/dompa/utils.cljc
index c25e841..5e57e2c 100644
--- a/src/dompa/utils.cljc
+++ b/src/dompa/utils.cljc
@@ -1 +1,36 @@
(ns dompa.utils)
+
+(defn- make-node
+ [name & opts]
+ (let [node {:name name}]
+ (if (get (first opts) :name)
+ (merge
+ node
+ (when-not (empty? opts)
+ {:children opts}))
+ (let [attrs (first opts)
+ [_ & children] opts]
+ (merge
+ node
+ {:attrs attrs}
+ (when-not (empty? children)
+ {:children children}))))))
+
+(defn doctype []
+ (make-node :!DOCTYPE {:html true}))
+
+(defn head [& opts]
+ (make-node :head opts))
+
+(defn body [& opts]
+ (make-node :body opts))
+
+(defn span [& opts]
+ (make-node :span opts))
+
+(comment
+ (list
+ (doctype)
+ (head)
+ (body
+ (span {:class "test"} (span {:class "test2"}))))) \ No newline at end of file