Nextjournal / Nov 26 2018
ClojureScript Template
ClojureScript Template

You can remix this template to get started with ClojureScript.
Please note that, currently, ClojureScript support is experimental. ClojureScript code is being evaluated in a WebWorker so DOM access and requiring external dependencies is limited.
There are two ways you can use ClojureScript in a Nextjournal article at the moment:
1. Use Plotly (comes pre-installed)
1.
Use Plotly (comes pre-installed)
(def x (range 0 1000)) (def y (map #(js/Math.sin (/ (* % (.-PI js/Math) 2) (count x))) x)) (.plot js/Nextjournal [{:x x :y y}])
2. Use Hiccup
2.
Use Hiccup
For now, you can use Hiccup for generating HTML and SVG content. Assigning Javascript event handlers will be ignored.
(defn circles [r] (let [size (* r 3)]) [:svg {:viewBox (str "0 0 " size " " size) :width size :height size} [:circle {:r r :cx r :cy (* r 2) :fill "#f00" :opacity 0.5}] [:circle {:r r :cx (* r 2) :cy (* r 2) :fill "#0f0" :opacity 0.5}] [:circle {:r r :cx (* r 1.5) :cy r :fill "#00f" :opacity 0.5}]]) {:kind "hiccup" :value (circles 50)}