diff options
| -rw-r--r-- | src/dompa/nodes.cljc | 4 | ||||
| -rw-r--r-- | test/dompa/nodes_test.cljc | 11 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/dompa/nodes.cljc b/src/dompa/nodes.cljc index 236271d..8600026 100644 --- a/src/dompa/nodes.cljc +++ b/src/dompa/nodes.cljc @@ -92,7 +92,7 @@ [name & args-and-elements] (let [[args & elements] args-and-elements] `(defn ~name ~args - (->html [~@elements])))) + (->html (vector ~@elements))))) (defn $ "Creates a new node @@ -114,4 +114,4 @@ children (if attrs? (rest opts) opts)] (cond-> {:node/name name} attrs? (assoc :node/attrs attrs) - (seq children) (assoc :node/children children))))) + (seq children) (assoc :node/children (flatten children)))))) diff --git a/test/dompa/nodes_test.cljc b/test/dompa/nodes_test.cljc index 8d39da1..2606be6 100644 --- a/test/dompa/nodes_test.cljc +++ b/test/dompa/nodes_test.cljc @@ -14,6 +14,17 @@ (is (= "<div>hello world</div>" (hello "world")))) +(defhtml list-items [items] + ($ :ul + (->> items + (map (fn [item] + ($ :li ($ item)))) + (into [])))) + +(deftest list-items-test + (is (= "<ul><li>one</li><li>two</li><li>three</li></ul>" + (list-items ["one" "two" "three"])))) + (deftest $-test (testing "a simple node" (is (= {:node/name :div |
