blob: 285566dc27794af5e89a1300941ca6fd41921a02 (
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
|
(ns dompa.utils
(:require [dompa.nodes :as nodes]))
(defmacro $ [name & opts]
(if (string? name)
{:name :dompa/text
:value name}
(let [node {:name name}
attrs? (map? (first opts))
attrs (if attrs? (first opts) {})
children (if attrs? (rest opts) opts)]
(merge
node
(when attrs?
{:attrs attrs})
(when-not (empty? children)
{:children (into [] children)})))))
(defn- page []
(list
($ :!doctype {:html true})
($ :html {:lang "en"}
($ :head
($ :meta {:charset "utf-8"})
($ :link {:rel "stylesheet" :href "style.css"}))
($ :body
($ :span {:class "test"}
($ :span {:class "test2"}
($ "hello, world.")))))))
(comment
($ "asdasd")
(page)
(nodes/->html (page)))
|