Fork me on GitHub
#clerk
<
2023-03-31
>
zane17:03:15

I’m noticing that in some situations Clerk seems to evaluate expressions that use clojure.spec specs before they’re defined. Is it possible that Clerk is not tracking spec definitions as part of its computation graph?

mkvlr19:03:16

possible, don’t think I understand this fully. How does the issue manifest?

zane19:03:59

I have a Clerk notebook that includes both s/def spec definitions as well as usages of s/valid? that refer to those definitions. I’m finding that when I use clerk/show! on the notebook I get errors signaling that the spec definitions are not yet defined.

zane19:03:18

Note that I don’t get those errors when I simply require the notebook namespace in the REPL.

mkvlr19:03:02

could you file an issue with a minimal repro?

zane19:03:05

I’m trying to create a minimal rep— yes.

🙏 2
zane19:03:35

It’s a challenge though because simply extracting out the spec definitions and a single usage seemingly isn’t enough to reproduce the behavior. I’ll see what I can do.

Jakub Holý (HolyJak)20:03:55

Hello! How do I switch over from one viewer into another? I.e. inside clerk/html I would like to render clojure data in the form clerk normally does. I am looking at the docs but not finding it…

David Ackerman21:03:23

you can generally embed other viewers directly in the hiccup https://book.clerk.vision/#hiccup,-html-&amp;-svg

Jakub Holý (HolyJak)21:03:55

Thank you. I saw the example with clerk/image already before. But it is not clear to me which viewer is the one that renders EDN data as an interactive, expandable thing. Do you know?

Sam Ritchie22:03:21

I think “inspect” will do it

Sam Ritchie22:03:42

Nextjournal.clerk.viewer/inspect

zane00:04:32

That’s right. You probably want some combination of inspect, inspect-presented, and present.

zane01:04:09

If you want an example, search this channel for the delay and future viewers I was working on earlier.

jackrusher06:04:05

We should add an example for this in the Book @U5H74UNSF @U9EQP1K0X

👍 2
mkvlr06:04:35

it’s nextjournal.clerk.render/inspect, not viewer

mkvlr06:04:29

if you have the data in the browser. If you’d like to switch from hiccup back to Clerk’s viewer system, use a wrapped value:

(clerk/html [:div
             [:h1 "Hiccup"]
             {:nextjournal/value (range 100)}])

mkvlr06:04:39

produces:

Jakub Holý (HolyJak)15:04:07

Awesome! Thank you! I would never discover {:nextjournal/value ..} trick through skimming the docs and namespaces. I am sure it is document somewhere, just not punching me in the eye :)

zane17:04:22

News to me as well. Thanks!