summaryrefslogtreecommitdiff
path: root/src/dompa/utils.cljc
blob: 5e57e2cfd5042187ff0547469e0b69a5dcee79e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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"})))))