basilisp.template¶
Macro templating utilities.
The utilities in this namespace may be used in macros to apply a single expression
to a sequence of inputs. For an example, see basilisp.test/are
.
- fn (apply-template argv expr values)[source]¶
Given a template expression
expr
and bindings (asargv
), replace all instances of elements fromargv
inexpr
with the corresponding elements fromvalues
.For example:
(apply-template '[x y] '(= x y) '[1 2])
produces:
(= 1 2)
- macro (do-template argv expr & args)[source]¶
Given a template expression
expr
and bindings, produce ado
expression with the repeated templated expressions replacing names inargv
with elements fromargs
.For example:
(macroexpand '(do-template [x y] (= x y) 1 (dec 2) 2 (inc 1)))
produces:
(do (= 1 (dec 2)) (= 2 (inc 1)))