Open martinklepsch opened 4 years ago
Hm... I thought I could also just call transform
but somehow I am not able to get this to work. Does look like it should work to you? Shouldn't all these forms return the same, i.e. ([:div])
?
(def html-str "<div><span>x</span></div>")
(def hs (utils/convert-to html-str :hiccup-seq))
(enlive/transform hs [:span] nil) ; => [[:div [:span "x"]]]
(-> (enlive/as-nodes hs)
(enlive/transform [:span] nil)) ; => [[:div [:span "x"]]]
(enlive/at hs [:span] nil) ; => ([:div])
@martinklepsch sorry bout the slow response. Been chasing butterflies.
I know an enlive/at
transform using nil as the transforming function deletes the node. But it looks like that does not apply to enlive/transform
and that nil here means just do nothing.
regarding the at*
exposure, defining the var in the namespace will make it accessible from the JVM, but it will need to be "mounted" for bootleg itself in namespaces.clj
and for babashka pod use in pod.clj
.
I added some more introspective macros in spire to automount the vars for sci usage, but bootleg is still manually listing them all.
enlive/at*
is a bit easier to use when programmatically passing selectors and transformations as collection.I'm not sure if this is the right way of doing it, let me know if you think this should be done differently.