Closed didibus closed 4 years ago
Yep. That is what hiccup-seq is. A sequence (a list) of hiccup forms.
$ bootleg -d -e '(convert-to "<p>one</p><p>two</p>" :hiccup-seq)'
([:p {} "one"] [:p {} "two"])
the reverse also works:
$ bootleg -e '(list [:p "one"] [:p "two"])'
<p>one</p><p>two</p>
Just testing, hiccup does support this sequence:
test2.core=> (use 'hiccup.core)
nil
test2.core=> (html (list [:p "one"] [:p "two"]))
"<p>one</p><p>two</p>"
Will update the documentation to make this clear
As an additional note, reagent proclaims to use hiccup syntax but does not support the list form.
In reagent:
(defn test-page []
(list [:p "one"] [:p "two"]))
(defn current-page []
(fn []
[:div
[test-page]]))
gives:
Error: Objects are not valid as a React child (found: object with keys {ns, name, fqn, _hash, cljs$lang$protocol_mask$partition0$, cljs$lang$protocol_mask$partition1$}). If you meant to render a collection of children, use an array instead.
in myreagent.core.test_page (created by myreagent.core.current_page)
in div (created by myreagent.core.current_page)
in myreagent.core.current_page 3 react-dom.inc.js:13951:28
Trying a vector:
(defn test-page []
(vector [:p "one"] [:p "two"]))
(defn current-page []
(fn []
[:div
[test-page]]))
results in
Error: No item [:p "two"] in vector of length 2 2 core.cljs:5383:9
defining a single hiccup form works:
(defn test-page []
(last (list [:p "one"])) [:p "two"])
(defn current-page []
(fn []
[:div
[test-page]]))
results in
<div><p>two</p></div>
In the readme, you mention hiccup can't represent sibling elements like:
But I'm pretty sure you can do this in Hiccup by wrapping it in a list like: