Fork me on GitHub
#clojurescript
<
2020-07-08
>
cfleming00:07:44

What’s the best solution for CLJS if I want to convert hiccup to a string? I found hiccups but it seems unmaintained and hasn’t had an update for 4 years or so. It doesn’t seem to support html5 output and it seems like it hasn’t kept up with mainline hiccup.

cfleming09:07:09

Don’t both of those create React nodes directly rather than creating an HTML string?

cfleming22:07:05

Actually, I see the reagent one does compile to a string, but using react which I’d rather avoid.

cfleming22:07:28

This is for server side node.

Jacob Emcken10:07:45

I'm trying to read EDN over a websocket which works fine until I try to transfer a regex. I recreated the "problem" without all the WS stuuf from a REPL:

> (cljs.tools.reader.edn/read-string (pr-str #"^\d{4}$"))
#error {:message "Unsupported escape character: \\d.", ...
I've also tried with cljs.reader/read-string which gives me the same error... if this is doable, then how?

Johnny12:07:34

regex patterns are not part of edn, @jacob429

Johnny12:07:34

Since they have to be compiled to a platform specific type and it was decided that it differs too much across platforms

Johnny12:07:52

If you eval the code, you can wrap strings in (re-pattern) as an alternative, but that may not be best practice

dominicm12:07:23

@jacob429 you should look at #C1DV21X9P's regal library.

Jacob Emcken13:07:51

thanks, might be what I need 🙂

dpsutton14:07:32

weird observed behavior. coworker had a node_modules directory from an experiement two years ago with react 16.3 in it. We are cljsjs/react otherwise and hadn't used any node_modules. We updated to cljs 1.10.773 yesterday and don't use the bundle target. Clojurescript still put our standard cljsjs/react and also the 16.3 react into the build. I was surprised that node_modules was seemingly added to compilation when there was no usage of the bundle target

dominicm14:07:47

@dpsutton indexing node_modules predates bundle.

dpsutton14:07:17

hmm. it wasn't an issue for him until we went from 1.10.439 -> 773. i'll see if i can make a repro

dpsutton14:07:38

interestingly, (vals "bob") throws under no optimizations and not under advanced which led to a confusing bug 🙂

dpsutton14:07:13

certainly a garbage in garbage out scenario but was surprising when trying to recreate the issue

dominicm14:07:29

A lot changed from 439->773. The change might predate 773/bundle.

dpsutton14:07:52

right. investigating now. just putting it out there to see if my surprise was warranted or not

chrismatheson18:07:20

hi all, ive got a bit of a confusing one that i cant seem to find any answer to with my google skills. im using reagent, and when i deref an atom using @thing im getting multiple values? (lib/ExpandRefs @lib) Wrong number of args (2) passed to app.lib/ExpandRefs

chrismatheson18:07:12

unfortunately if i log the arguments out to the conosole they arent much use to me to figure out what they are (and then hopefully where they were comming from)

chrismatheson18:07:32

if anyone has any clues i would be most appreciative!! 😄

lilactown18:07:57

it’s not possible for @thing to return two values so it is something else in your code

phronmophobic18:07:34

I think the issue is that lib/ExpandRefs is expecting 2 arguments, not receiving 2 arguments. ooops, nvmd

chrismatheson18:07:50

if i add a 2nd argument to lib/Expanded func and log both those i do see 2 “things”

chrismatheson18:07:13

(defn ExpandRefs [lib]
  "repeat transform untill there are no modifications"
  (js/console.log "----\n" lib)
  (fn inner [graph]
    (let [before graph
          after (insta/transform {:ref (fn [r] (lookup-ref lib r))} graph)]
      (cond (= before after) after
            :else (inner after)))))

euccastro19:07:46

Not related to your problem, but the docstring goes before the argument list

chrismatheson18:07:57

i can add a 2nd arg to this definition and then the error goes away (but the program blows up anyway )

noisesmith18:07:42

try checking the stack - the call might be coming from an unexpected place

chrismatheson18:07:58

…. how would one go about that? 😉

noisesmith18:07:00

also, what does the call look like? could it accidentally be inside -> or doto or .. ?

chrismatheson18:07:15

it is inside a -> yes

chrismatheson18:07:23

:else (-> f ExpandRefs Evaluate ToHtml))))

chrismatheson18:07:04

chuffing new slack input box!!!

chrismatheson18:07:49

i thought the threading macro -> would insert the value as the last arg, so i assumed if i return a 1 arg function it would insert it ?

noisesmith18:07:52

if you make a breakpoint in your browser js env you can inspect the stack in that debugger

chrismatheson18:07:56

its a macro!!!

chrismatheson18:07:16

its doing the insertion at “compile” time not runtime 🙂

chrismatheson18:07:34

is there a runtime alternative thats a quick switch ?

noisesmith18:07:03

you can use comp - replace (-> x f g h) with ((comp h g f) x)

noisesmith18:07:13

that only works for single arg functions though

chrismatheson18:07:37

yeah compose should work for me. thanks a ton, maybe even just the rubber ducking 😄