Functions useful for writing custom Clerk viewers.
Functions useful for writing custom Clerk viewers.
(compile-form aliases skel)Given a map aliases of <symbol> => <namespace object> and a Clojure
expression tree skel, returns skel with
Used by q.
Given a map `aliases` of `<symbol> => <namespace object>` and a Clojure expression tree `skel`, returns `skel` with - any splices or unquote-splices resolved from the environment - any symbol namespaced by an alias substituted for a symbol with namespace expanded. Used by [[q]].
(compile-sym aliases sym)Given a map aliases of <symbol> => <namespace object> and a symbol sym,
returns sym with its namespace expanded if that namespace is present in
aliases, sym otherwise.
For example:
(require '[clojure.core :as c])
(compile-sym (ns-aliases *ns*) 'c/cake)
;; => 'clojure.core/cake
Given a map `aliases` of `<symbol> => <namespace object>` and a symbol `sym`, returns `sym` with its namespace expanded if that namespace is present in `aliases`, `sym` otherwise. For example: ```clj (require '[clojure.core :as c]) (compile-sym (ns-aliases *ns*) 'c/cake) ;; => 'clojure.core/cake ```
(map-kv vf m)(map-kv kf vf m)Returns a map of identical type and key set to m, with each value v
transformed by the supplied function vf into (vf v) and each key k
transformed into (kf k).
In the 2-arity case, only values are transformed.
Returns a map of identical type and key set to `m`, with each value `v` transformed by the supplied function `vf` into `(vf v)` and each key `k` transformed into `(kf k)`. In the 2-arity case, only values are transformed.
(q form)q is similar to Clojure's unquote facility, except that
For example:
(require '[clojure.core :as c])
(let [x 10]
  (q (+ ~x c/y z ~@[4 5])))
;;=> (+ 10 clojure.core/y z 4 5)
[[q]] is similar to Clojure's `unquote` facility, except that - symbols are not automatically prefixed by namespace, - splices and unquote splices are respected, and - any symbol namespaced by an alias will have its namespace expanded. For example: ```clojure (require '[clojure.core :as c]) (let [x 10] (q (+ ~x c/y z ~@[4 5]))) ;;=> (+ 10 clojure.core/y z 4 5) ```
(splice-reduce f xs)Helper function for reducing over a sequence that might contain forms that need
to be spliced into the resulting sequence. This is a sort of helper for a
guarded mapcat.
Takes a sequence xs and mapping function f and returns a sequence of
sequences that, if concatenated together, would be identical to
(map f xs)
Except that any x such that (unquote-splice? x) returns true would have
its sequential value x spliced into the result instead of (f x).
Helper function for reducing over a sequence that might contain forms that need to be spliced into the resulting sequence. This is a sort of helper for a guarded `mapcat`. Takes a sequence `xs` and mapping function `f` and returns a sequence of sequences that, if concatenated together, would be identical to ```clojure (map f xs) ``` Except that any `x` such that `(unquote-splice? x)` returns true would have its sequential value `x` spliced into the result instead of `(f x)`.
(unquote-splice? form)Returns true if form is a sequence form that should be spliced directly into
the returned form, false otherwise.
Returns true if `form` is a sequence form that should be spliced directly into the returned form, false otherwise.
(unquote? form)Returns true if form is a form that should be included with no quoting into
the returned form, false otherwise.
Returns true if `form` is a form that should be included with no quoting into the returned form, false otherwise.
(unquoted-form form)Given a form that responds true to unquote? or unquote-splice?,
returns the unquoted body.
Given a `form` that responds `true` to [[unquote?]] or [[unquote-splice?]], returns the unquoted body.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs | 
| ← | Move to previous article | 
| → | Move to next article | 
| Ctrl+/ | Jump to the search field |