enlive
enlive copied to clipboard
hiccup-style adapter doesn't cope well with transformation results
This was surprising:
> (html (at (html [:a])
[:a] (content "foo")))
ClassCastException [trace missing]
(Finding the cause was "fun"; there's no stacktrace because the failure is in the destructuring of the first map element in the vector result of at
.)
Anyway, the workaround is easy (seq
around the result of at
). The impl of nodify
should probably fall through to the (sequential? node-spec)
case if node-spec
is a vector with a map for a first element.
Trace back when compiled against clojure 1.7: ClassCastException clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.Named clojure.core/name (core.clj:1524) Incoming...
Would this fit?
(html (at (html [:a])
[:a] (content "foo")))
=> ({:tag :a, :attrs {}, :content ("foo")})