From af83d8c7cdf85b675016eeeecaa85bb547141f4b Mon Sep 17 00:00:00 2001 From: Asko Nõmm Date: Fri, 26 Sep 2025 19:22:23 +0300 Subject: On second thought it's really not related to templating, just nodes, so moving to nodes ns. --- src/dompa/templates.cljc | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 src/dompa/templates.cljc (limited to 'src/dompa/templates.cljc') diff --git a/src/dompa/templates.cljc b/src/dompa/templates.cljc deleted file mode 100644 index 2f79fd2..0000000 --- a/src/dompa/templates.cljc +++ /dev/null @@ -1,37 +0,0 @@ -(ns dompa.templates - (:require [dompa.nodes :as nodes])) - -(defmacro defhtml - [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#)))))) -- cgit v1.2.3