According to the HTML5 spec, the <title>
tag's ContentModel is Text, which means that HTML elements are not allowed within it.
The part of Enlive that parses the HTML can probably only handle valid HTML, so it won't play nicely with the <span>
tag inside the <title>
tag.
You've got a few options.
It is possible to just set the content of the <title>
tag rather than substituting it completely, like this:
(html/sniptest "<html><head><title>Placeholder</title></head></html>"
[:title] (html/content "foo"))
;; => <title>foo</title>
Or if you want to keep a part of the title constant, you could use append
or prepend
(html/sniptest "<html><head><title>Some Title</title></head></html>"
[:title] (html/append " - sub page"))
;; => <title>Some Title - sub page</title>
EDIT
I know that you said you want to avoid ${vars}
, but in this case, they happen to do exactly what you're looking for...
(html/sniptest "<html><head><title>${my-site} - ${article-name}</title></head></html>"
[:title] (html/transform-content
(html/replace-vars
{:article-name "Using Enlive for good and evil"
:my-site "Clojure Weekly"})))
;; => <title>Clojure Weekly - Using Enlive for good and evil</title>