devcards 2016-07-21

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

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

for server side rendering

its really not used and super brittle

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

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

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

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

I really don't think its worth the effort

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

that was quite a while ago now

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

in node that is

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

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

render-namespace-to-string

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

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

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

@anmonteiro: before you make any render calls

makes sense, yeah

let me try that

thats if things start up in node at all 🙂

and I would start by passing an explicit ns

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

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

my mistake

call get-cards-for-ns directly

trying again

wrong namespace 🙂

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

correct ns now. I clearly must be doing something wrong

and you called load-data ...

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

otherwise they are compiled out of the build

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

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

but that's a big change

literally the opposite

@bhauman: still no dice

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

and you are calling load .... ?

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

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

then make sure that those files are getting loaded

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

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

@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

¯\(ツ)/¯

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

so kudos to you!

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

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

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

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

Only if you think it's valuable