I think fragments will work in this case.
Try something along these lines:
(html/sniptest "<div><a href=\"url\">Label</a><br/></div>" {[:a] [:br]}
(clone-for [{label :label url :url} [{:label "Google" :url "http://www.google.com" }
{:label "Stack Overflow" :url "http://www.stackoverflow.com"}]]
[:a] (do-> (content label)
(set-attr :href url)))))
;; =>
<div>
<a href="http://www.google.com">Google</a><br />
<a href="http://www.stackoverflow.com">Stack Overflow</a><br />
</div>
If you always want the full content of the div to be cloned (not just the fragment :a -> :br
) then you can use first-child
and last-child
. Just change the {[:a] [:br]}
selector above to {[:div first-child] [:div last-child]}
.