Open danielcompton opened 7 years ago
You should be able to wrap it in hiccup2.core/html
:
(hiccup2/html (page/html5 ...))
But a hiccup2.page namespace (or similar) is certainly on the agenda.
Ah right, that makes sense, I'll do that instead. Thanks!
I tried that, and it didn't seem to work, the h2/html
was re-escaping the html5
document.
;; requires:
;; [hiccup2.core :as h2]
;; [hiccup.core :as h]
;; [hiccup.page :refer [html5]
(str
(h/html
(html5
[:h1 "Available commands"])
))
=> "<!DOCTYPE html>\n<html><h1>Available commands</h1></html>"
(str
(h2/html
(html5
[:h1 "Available commands"])
))
=> "<!DOCTYPE html>\n<html><h1>Available commands</h1></html>"
I'm happy with my own html5
macro for now, but just thought I'd mention it. Also, I may have done something dumb in the above ^^.
@danielcompton I've seen the same behaviour
Since I wanted the escaping behavior for my projects, I've forked this repo to move the relevant namespaces under hiccup2. The html5 macro is at hiccup2.page/html5. The lein coordinates are [org.clojars.john-shaffer/hiccup "2.0.0-SNAPSHOT"]
I tried to use -alpha version tagging, but for some reason I get a compile-time error "Syntax error compiling at (hiccup2/core.clj:30:28). No such var: compiler/compile-html-with-bindings" if I do that, even though absolutely everything is the same except the version string.
I added the function hiccup.element/html-comment, as I'm basing my page off files from https://templated.co/, and I want to preserve the attribution.
Edit: Now I get that same error even with a SNAPSHOT version. Everything works fine when I copy the new files into my website repo and use [hiccup "2.0.0-alpha2"], even though that puts the exact same code on the classpath. I thought that maybe a dependency was including hiccup, but that's not the case.
Thanks, @john-shaffer ! I have the same situation where your fork only works if I inline the code. But, hey, it works!
@PEZ I've actually been using Rum's server-side rendering, since it provides the same auto-escaping functionality but can also be used with ClojureScript. I would highly recommend giving it a look.
I'm adopting hiccup2 on a project, but noticed that hiccup.page doesn't have a hiccup2 version. This means as far as I can tell, the only way to get the
html5
macro or others is to make a copy of them from hiccup into my own code, and change thehtml
reference to point tohiccup2.core/html
. Would you consider having other necessary namespaces ported over, or is there another way to do this?