Fork me on GitHub
#reagent
<
2015-09-16
>
tel19:09:23

How do you guys write body text in reagent templates?

tel19:09:40

Anyone know a way to have, e.g., inline Markdown?

gadfly36119:09:03

I've done it where i convert markdown to html then use dangerously set inner html https://facebook.github.io/react/tips/dangerously-set-inner-html.html

tel19:09:20

Oh, I mean something much more prosaic. Reagent’s semi-hiccup is nice for structuring the page, but rough for formatting text I’m writing in templates. I’d like to avoid [:p “Template syntax like “ [:strong “this”] “!”]

tel19:09:44

something like [:p (markdown “Template syntax like *this*!”)] would be wonderful

donmullen20:09:36

@tel: Not reagent - but you might learn something from looking at the hoplon code — they use markdown extensively in some of their demos : https://github.com/tailrecursion/hoplon.io/blob/master/src/index.cljs.hl#L96-L104

donmullen20:09:41

So looks like they are processing the MD as part of generating the code — and not processing on the clojurescript/client side.

tel20:09:37

yeah, that’s clever

tel20:09:42

and sort of wild

tel21:09:31

is there an xml->reagent function floating around anywhere?

gadfly36121:09:07

I'm not sure, but hickory might be of interest - html to hiccup

danielcompton22:09:14

@jaen: what did you find hard about hooking into dispose in Reagent?

jaen22:09:10

I'd have to go over the code again, it was a while ago, I can get back to you with more details later-ish, after I go read that code again, if you want. But basically I wanted to have reactive query objects - I do (logic/query [:some datascript]) and get back a reactive object that forces re-render when the output of query changes. To do that I had to register datascript callbacks via d/listen! and to not have this grow in an unbounded manner I would have to hook unlistening on when the reactive query gets disposed on component unmount.

danielcompton22:09:48

@jaen I’m working on something veeeerry similar with RethinkDB

danielcompton22:09:02

What we did was to create a Reaction off the Ratom, and add an :on-dispose key in ratom/make-reaction. When Reagent detects that the reaction isn’t being watched anymore it will call the on-dispose that cleans up the parent ratom

jaen22:09:40

So I kind wrapped everything in a reaction, but I must have missed the :on-dispose key

jaen22:09:29

If that works then maybe I can keep using reagent

jaen22:09:34

Also, isn't rethinkdb server-side?

danielcompton22:09:46

But same principle

jaen22:09:14

Interesting

danielcompton22:09:47

It’s a little tied into re-frame, but none of it is re-frame exclusive

jaen22:09:04

In general this feels like a good direction, some transient local state and automagic synchonisation of perrsistent state between the frontend and backend.

jaen22:09:46

I didn't use reframe, but what I wrote was for myself was basically guided by reframe readme ; d

jaen22:09:54

I figured maybe I'll better understand it that way

tel22:09:18

meteor has some significant prior art there

zane22:09:29

@jaen: You're re-running all queries whenever the db changes?

jaen22:09:56

Yes, I don't think I did anything significantly smarter than that

zane22:09:32

@jaen: If I'm understanding that means that any part of the UI that depends on those reactive queries re-renders on any db change, right?

danielcompton23:09:35

@zane only if the query actually changes, Reagent won’t update otherwise (modulo identical? vs = checking)

zane23:09:00

Got it. It'll fall back from identical? to =, you mean?

danielcompton23:09:19

Not sure if @jaen’s queries/datascript will return results from a query that are identical?. If they are then Reagent won’t update, if they’re not identical it may. Depends a little on how it’s being used, I’m mostly familiar with re-frame’s pattern. More info in above link.