summaryrefslogtreecommitdiff
path: root/src/dompa/utils.cljc
diff options
context:
space:
mode:
authorAsko Nõmm <asko@nmm.ee>2025-09-25 21:39:10 +0300
committerAsko Nõmm <asko@nmm.ee>2025-09-25 21:39:10 +0300
commitcf55a6a6688c54527a3d27a8d6027858ced99257 (patch)
tree482723e4e51bbd02563ebd9bd6630c87ff36b2a4 /src/dompa/utils.cljc
parent3714b9c97609adc2b48b66c293259a0b5c3eddf6 (diff)
Rename utils to templates, as it is more appropriate.
Diffstat (limited to 'src/dompa/utils.cljc')
-rw-r--r--src/dompa/utils.cljc48
1 files changed, 0 insertions, 48 deletions
diff --git a/src/dompa/utils.cljc b/src/dompa/utils.cljc
deleted file mode 100644
index 0396e8a..0000000
--- a/src/dompa/utils.cljc
+++ /dev/null
@@ -1,48 +0,0 @@
-(ns dompa.utils
- (:require [dompa.nodes :as nodes]))
-
-(defmacro defhtml
- {:clj-kondo/lint-as 'clojure.core/defn}
- [name & args-and-elements]
- (let [[args & elements] args-and-elements]
- `(defn ~name ~args
- (nodes/->html (vector ~@elements)))))
-
-(defn ->flat-xf []
- (fn [rf]
- (letfn [(step [result input]
- (if (sequential? input)
- (reduce step result input)
- (rf result input)))]
- (fn
- ([] (rf))
- ([result] (rf result))
- ([result input] (step result input))))))
-
-(defn ->flat [children]
- (into [] (->flat-xf) children))
-
-(defmacro $
- [name & opts]
- `(if (string? ~name)
- {:node/name :dompa/text
- :node/value (str ~name ~@opts)}
- (let [opts# (list ~@opts)
- first-opt# (first opts#)
- attrs?# (and (map? first-opt#)
- (not (contains? first-opt# :node/name)))
- attrs# (if attrs?# first-opt# {})
- children# (if attrs?# (rest opts#) opts#)]
- (cond-> {:node/name ~name}
- attrs?# (assoc :node/attrs attrs#)
- (seq children#) (assoc :node/children (->flat children#))))))
-
-(defhtml test-page []
- (let [n 123]
- ($ :<>
- ($ :div
- ($ "hello world" n))
- ($ "hello")
- ($ :div))))
-
-(test-page)