Fork me on GitHub
#devcards
<
2016-07-21
>
anmonteiro20:07:45

@bhauman: what’s the purpose of the html-env? function in devcards?

anmonteiro20:07:19

I can see you e.g. define some React lifecycle functions conditionally based on that

bhauman20:07:20

for server side rendering

bhauman20:07:32

its really not used and super brittle

anmonteiro20:07:58

@bhauman: Right, I suspected that. but there are things like js/document.getElementById that are used throughout the code

bhauman20:07:04

but basically I got the code to run in node for blog post rendering etc

bhauman20:07:33

yeah but server side rendering doesn't use those code paths

anmonteiro20:07:57

@bhauman: I wanna make the devcards-om-next stuff compatible with that too. could you point me to the code paths that it uses?

bhauman20:07:26

I really don't think its worth the effort

bhauman20:07:48

I haven't used that code since I first wrote it and it may not work anymore

bhauman20:07:56

that was quite a while ago now

bhauman21:07:19

If I were you I would see if I can render a devcard page in the first place

bhauman21:07:31

in node that is

bhauman21:07:43

all the code for this is at the bottom of core.cljs

anmonteiro21:07:35

@bhauman: thanks, render-namespace-to-string seems to be one of the things I’m looking for

bhauman21:07:42

render-namespace-to-string

bhauman21:07:17

yeah if it renders to string bully for you ...

anmonteiro21:07:21

@bhauman: this should work, I supose: (render-namespace-to-string *ns*)

bhauman21:07:37

you also have to call load-data-from-channel

bhauman21:07:13

@anmonteiro: before you make any render calls

anmonteiro21:07:34

makes sense, yeah

anmonteiro21:07:39

let me try that

bhauman21:07:59

thats if things start up in node at all 🙂

bhauman21:07:30

and I would start by passing an explicit ns

bhauman21:07:11

and you also have to differentiate between the code that is just the card code and the code that is in the card... because the card may render but the card content may not. So starting with a bare hello world project may make more sense

anmonteiro21:07:25

@bhauman: hrm, no errors, but render-namespace-to-string returns nil

bhauman21:07:09

call get-cards-for-ns directly

anmonteiro21:07:11

trying again

anmonteiro21:07:21

wrong namespace 🙂

anmonteiro21:07:32

@bhauman: get-cards-for-ns also returning nil

anmonteiro21:07:44

correct ns now. I clearly must be doing something wrong

bhauman21:07:56

and you called load-data ...

bhauman21:07:21

oh you must make sure that you have devcards true in the :compiler

bhauman21:07:35

otherwise they are compiled out of the build

anmonteiro21:07:44

oh wow, now I then that comes to bite me again

bhauman21:07:14

yeah I really want to make it opt-out instead of opt-in

bhauman21:07:21

but that's a big change

bhauman21:07:30

literally the opposite

anmonteiro21:07:12

@devcards.system/app-state returns the initial state without any cards

bhauman21:07:24

and you are calling load .... ?

bhauman21:07:25

I would make sure that the cards are in the build and clean and rebuild etc

anmonteiro21:07:12

there are definitely calls to devcards.core.register_card in the compiled JS

bhauman21:07:58

then make sure that those files are getting loaded

anmonteiro21:07:17

@bhauman: so it needs to block in load-data-from-channel! somehow

anmonteiro21:07:37

it’s only getting the register_card calls after I call render-namespace-to-string

anmonteiro21:07:52

@bhauman: so a few problems I had to get through: 1. load-data-from-channel! needed to be called like this: (go (<! (dc/load-data-from-channel!))) 2. my NS had - which were munged so I needed to pass the munged symbol to render-namespace-to-string 3. now getting an error with React.renderToString because it moved to ReactDOMServer.renderToString in later versions of React

anmonteiro22:07:42

using my own version of render-namespace-to-string works (just replaced React.renderToString with ReactDOMServer.renderToString)

anmonteiro22:07:56

so kudos to you!

bhauman22:07:57

I'll take a PR for sure, perhaps some doc strings?

bhauman22:07:14

I'm really glad you made it through ...

anmonteiro22:07:51

@bhauman: I’ll put something together in the next few days

anmonteiro22:07:18

maybe also convert from demunged ns symbols to the actual (munged) keyword that devcards uses internally

bhauman22:07:22

Only if you think it's valuable