|
1 | | -;; # Compile viewer functions using cherry |
| 1 | +;; # 🍒 Compile viewer functions using cherry |
2 | 2 | (ns cherry |
3 | | - {:nextjournal.clerk/render-evaluator :cherry} |
| 3 | + {:nextjournal.clerk/render-evaluator :cherry |
| 4 | + :nextjournal.clerk/toc true} |
4 | 5 | (:require [nextjournal.clerk :as clerk] |
5 | 6 | [nextjournal.clerk.viewer :as viewer])) |
6 | 7 |
|
|
19 | 20 | (pr-str (interleave (cycle [1]) (frequencies [1 2 3 1 2 3])))))]) |
20 | 21 | {:nextjournal.clerk/render-evaluator :sci} nil) |
21 | 22 |
|
22 | | -;; Better performance: |
| 23 | +;; ## ⏱️ Better performance: |
23 | 24 |
|
24 | 25 | (clerk/with-viewer |
25 | 26 | '(fn [value] |
|
54 | 55 | :key "id" :fields ["rate"]}}] |
55 | 56 | :projection {:type "albersUsa"} :mark "geoshape" :encoding {:color {:field "rate" :type "quantitative"}}}) |
56 | 57 |
|
57 | | -;; ## Input text and compile on the fly with cherry |
| 58 | +;; ## 🔨 Input text and compile on the fly with cherry |
58 | 59 |
|
59 | 60 | (clerk/with-viewer |
60 | 61 | {;; :evaluator :cherry |
|
80 | 81 | {:nextjournal.clerk/render-evaluator :cherry} |
81 | 82 | nil) |
82 | 83 |
|
83 | | -;; ## Functions defined with `defn` are part of the global context |
| 84 | +;; ## 🌍 Functions defined with `defn` are part of the global context |
84 | 85 |
|
85 | 86 | ;; (for now) and can be called in successive expressions |
86 | 87 |
|
87 | 88 | (clerk/eval-cljs-str "(defn foo [x] (this-as this (inc x)))") |
88 | 89 |
|
89 | 90 | (clerk/eval-cljs-str "(foo 1)") |
90 | 91 |
|
91 | | -;; ## Async/await works cherry |
| 92 | +;; ## 🚦Async/await works cherry |
92 | 93 |
|
93 | 94 | ;; Here we dynamically import a module, await its value and then pull out the |
94 | 95 | ;; default function, which we expose as a global function. Because s-expressions |
|
112 | 113 | [nextjournal.clerk.render/render-promise |
113 | 114 | (emoji-picker)]) nil) |
114 | 115 |
|
115 | | -;; ## Macros |
| 116 | +;; ## 🧩 Macros |
116 | 117 |
|
117 | 118 | (clerk/eval-cljs |
118 | 119 | '(defn clicks [] |
|
123 | 124 |
|
124 | 125 | (clerk/with-viewer '(fn [_] (this-as this [clicks])) nil) |
125 | 126 |
|
126 | | -;; ## Evaluator option as form metadata |
| 127 | +;; ## 👻 Evaluator option as form metadata |
127 | 128 | ^{::clerk/visibility {:code :hide :result :hide} ::clerk/no-cache true} |
128 | 129 | (clerk/add-viewers! [(assoc viewer/code-block-viewer :transform-fn (viewer/update-val :text))]) |
129 | 130 |
|
|
0 commit comments