Fork me on GitHub

I am working on a re-frame app and need to give some raw HTML to printJS. I can do it with pp/cl-format but thought my non-CL peers might appreciate a Hiccup solution. Is the way to go for that? I see Reagent itself renders straight to the DOM, so has no text HTML output capability. Unless I missed it. 🙂


Out of interest - what's pp/cl-format?


Ah, cljs.pprint, right.


I was confused initially, but I think I get what you want now. Just as a clarification - Reagent doesn't render anything. It simply creates React elements, React then makes a vDOM tree out of them, then reconciles it with the real DOM, IIRC. With that being said, you can still use it by creating an off-screen element and putting that HTML inside. Unless it's not just some markup but a proper HTML that can't be put inside <div>. Just in case - if you have a server, then using Clojure might be better. At the very least, it would help you avoid an extra dependency in the browser that would be used for just one thing (actually, cljs.pprint has significant size at all, when bundled with the rest of the app - I wouldn't want to use it for just one thing as well).


Right, Reagent just writes to the DOM, that is why I am looking at teropa/hiccups to generate some text HTML to pass to


you can always just render into a div and then use (.-innerHTML the-div) to get the full html. if you just have some data and don't need all the rendering stuff reagent/re-frame do then hiccups is fine too.


Also note that cljs.pprint isn't very friendly on your bundle size


Yikes! We have two functions in reagent.dom.server: render-to-static-markup and render-to-string! I was googling sth else when these jumped onto my radar. Weird, I had looked for sth like that...ah, I got as far as reagent.dom but never considered r.d.server. sigh


Hey, what's the best practice for including a cljs library from a specific commit on github?


@kimo deps.edn + :git/url ?


I run into this issue from time to time when booting my Clojurescript project up:

009 |     (if (js/isFinite o)
1010 |       (js-mod (Math/floor o) 2147483647)
1011 |       (case o
1012 |         ##Inf
No reader function for tag Inf
using deps… but running clj -A:dev:test -Stree doesn’t show an outdated tools.reader that doesn’t support the ##Inf literal, and I don’t know how else to debug ⛽ 🔦

Alex Miller (Clojure team)22:06:21

Could be tools.reader embedded in something else (like cljs)


:thinking_face: it’s a pretty recent version of Clojurescript (from the stacktrace):

File: jar:file:/.m2/repository/org/clojure/clojurescript/1.10.773/clojurescript-1.10.773.jar!/cljs/core.cljs:1012:14