I ended up having to modify overthink's answer to get it working.
(defn extract-body
"Enlive uses TagSoup to parse HTML. Because it assumes that it's dealing with
something potentially toxic, and tries to detoxify it, it adds <head> and
<body> tags around any HTML you give it. So the DOM returned by html-resource
has these extra tags which end up wrapping the content in the middle of our
webpage. We need to strip these extra tags out."
[html]
(html/at html [#{:html :body}] html/unwrap))
(html/defsnippet logout "templates/logout.html" [html/root] [])
How wrap
works is it wraps selected elements in a given tag. So in this case, #log_out
is selected and is wrapped with the li
tag.
(html/defsnippet nav "templates/nav.html" [html/root]
[]
[:ul] (html/append (extract-body (logout)))
[:#log_out] (html/wrap :li))
It's definitely not as clean as I'd like, but it works.