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
exprand bindings (asargv), replace all instances of elements fromargvinexprwith 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
exprand bindings, produce adoexpression with the repeated templated expressions replacing names inargvwith 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)))