@@ -473,20 +473,13 @@ v/default-viewers
473
473
; ; transforms it such that Clerk can send it to the browser where it
474
474
; ; will be rendered.
475
475
476
-
477
- ^{::clerk/visibility {:code :fold :result :hide }}
478
- (defn show-raw-value [x]
479
- (binding [*print-namespace-maps* false ]
480
- (clerk/code (with-out-str (clojure.pprint/pprint x)))))
481
-
482
476
; ; Let's start with one of the simplest examples. You can see that
483
477
; ; `present` takes our value `1` and transforms it into a map, with
484
478
; ; `1` under a `:nextjournal/value` key and the number viewer assigned
485
479
; ; under the `:nextjournal/viewer` key. We call this map a
486
480
; ; `wrapped-value`.
487
481
488
-
489
- ^{::clerk/viewer show-raw-value}
482
+ ^{::clerk/viewer v/inspect-wrapped-values ::clerk/auto-expand-results? true }
490
483
(v/present 1 )
491
484
492
485
; ; This data structure is sent over Clerk's websocket to the
@@ -495,7 +488,7 @@ v/default-viewers
495
488
496
489
; ; Now onto something slightly more complex, `#{1 2 3}`.
497
490
498
- ^{::clerk/viewer show-raw-value }
491
+ ^{::clerk/viewer v/inspect-wrapped-values ::clerk/auto-expand-results? true }
499
492
(v/present #{1 2 3 })
500
493
501
494
@@ -524,13 +517,14 @@ v/default-viewers
524
517
; ; When writing your own viewer, the first extension point you should reach for is `:tranform-fn`.
525
518
526
519
#_ " exercise: wrap this in `v/present` and call it at the REPL"
527
- (v/with-viewer {:transform-fn #( clerk/html [ :pre ( pr-str %)]) }
520
+ (v/with-viewer {:transform-fn v/inspect-wrapped-values }
528
521
" Exploring the viewer api" )
529
522
530
523
; ; As you can see the argument to the `:transform-fn` isn't just the
531
- ; ; string we're passing it, but a `wrapped-value`. We will look at
532
- ; ; what this enables in a bit. But let's look at one of the simplest
533
- ; ; examples first.
524
+ ; ; string we're passing it, but a map with the original value under a
525
+ ; ; `:nextjournal/value` key. We call this map a `wrapped-value`. We
526
+ ; ; will look at what this enables in a bit. But let's look at one of
527
+ ; ; the simplest examples first.
534
528
535
529
; ; **A first simple example**
536
530
@@ -543,7 +537,7 @@ v/default-viewers
543
537
" James Clerk Maxwell" )
544
538
545
539
; ; The `:transform-fn` runs on the JVM, which means you can explore what it does at your REPL by calling `v/present` on such a value.
546
- ^{::clerk/viewer show-raw-value }
540
+ ^{::clerk/viewer v/inspect-wrapped-values }
547
541
(v/present (v/with-viewer greet-viewer
548
542
" James Clerk Maxwell" ))
549
543
@@ -580,7 +574,7 @@ v/table-viewer
580
574
; ; `clerk/mark-presented` as a `:transform-fn`. Compare the result
581
575
; ; below in which `[1 2 3]` appears unaltered with what you see above.
582
576
583
- ^{::clerk/viewer show-raw-value }
577
+ ^{::clerk/viewer v/inspect-wrapped-values }
584
578
(v/present (clerk/with-viewer {:transform-fn clerk/mark-presented
585
579
:render-fn '(fn [x] [:pre (pr-str x)])}
586
580
[1 2 3 ]))
@@ -591,7 +585,7 @@ v/table-viewer
591
585
; ; `clerk/mark-preserve-keys`. This will still transform (and
592
586
; ; paginate) the values of the map, but leave the keys unaltered.
593
587
594
- ^{::clerk/viewer show-raw-value }
588
+ ^{::clerk/viewer v/inspect-wrapped-values ::clerk/auto-expand-results? true }
595
589
(v/present (clerk/with-viewer {:transform-fn clerk/mark-preserve-keys}
596
590
{:hello 42 }))
597
591
0 commit comments