Fork me on GitHub
#clerk
<
2023-07-18
>
teodorlu13:07:32

Hi! It’s possible to hide code with metadata on the form:

^{:nextjournal.clerk/visibility {:code :hide}}
(str "my" " " "value")
Is it possible to control code visibility with the return value from a function? I want to make a convenience function that returns HTML, and avoid having to tag each form invoking my function with metadata to hide code.

teodorlu13:07:23

I suspect I might be able to solve this with a custom viewer, but I’m not quite sure where to start. Viewers like clerk/html and clerk/md change the presentation of the result, but not the code.

teodorlu13:07:23

Reading https://book.clerk.vision/#viewers now, perhaps I can use a :transform-fn.

Andrea13:07:13

to my knowledge that’s one thing we still cannot do in the transform-fn, but it’s been requested in the past

👍 2
Andrea13:07:29

I’ve been a bit away from clerk development recently though

👍 2
sohalt13:07:42

Oops, I actually misread your question 🙈 Ignore what I said…

🙂 2
teodorlu14:07:35

I tried a bit more, and could only confirm what Andrea said: :transform-fn can’t change visibility. So form metadata it is!

👍 2
Andrea14:07:02

I think we want to allow that at some point

👍 2