Fork me on GitHub
#clojurescript
<
2021-06-01
>
kennytilton06:06:24

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 https://github.com/teropa/hiccups 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. 🙂

p-himik06:06:07

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

p-himik06:06:25

Ah, cljs.pprint, right.

p-himik07:06:05

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).

kennytilton07:06:12

Right, Reagent just writes to the DOM, that is why I am looking at teropa/hiccups to generate some text HTML to pass to https://printjs.crabbly.com/

thheller07:06:38

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.

borkdude10:06:46

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

kennytilton00:06:55

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

km18:06:08

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

borkdude20:06:13

@kimo deps.edn + :git/url ?

haywood22:06:30

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)

haywood22:06:44

: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