summaryrefslogtreecommitdiff
path: root/src/dompa/utils.cljc
diff options
context:
space:
mode:
Diffstat (limited to 'src/dompa/utils.cljc')
-rw-r--r--src/dompa/utils.cljc47
1 files changed, 30 insertions, 17 deletions
diff --git a/src/dompa/utils.cljc b/src/dompa/utils.cljc
index 1a6bff7..285566d 100644
--- a/src/dompa/utils.cljc
+++ b/src/dompa/utils.cljc
@@ -1,21 +1,34 @@
-(ns dompa.utils)
+(ns dompa.utils
+ (:require [dompa.nodes :as nodes]))
(defmacro $ [name & opts]
- (let [node# {:name (keyword 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)}))))
+ (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)})))))
-(comment
+(defn- page []
(list
- ($ doctype {:html true})
- ($ head)
- ($ body
- ($ span {:class "test"}
- ($ span {:class "test2"}))))) \ No newline at end of file
+ ($ :!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))) \ No newline at end of file