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)

Given a template expression expr and bindings (as argv), replace all instances of elements from argv in expr with the corresponding elements from values.

For example:

(apply-template '[x y] '(= x y) '[1 2])

produces:

(= 1 2)
macro (do-template argv expr & args)

Given a template expression expr and bindings, produce a do expression with the repeated templated expressions replacing names in argv with elements from args.

For example:

(macroexpand '(do-template [x y] (= x y)
                1 (dec 2)
                2 (inc 1)))

produces:

(do
  (= 1 (dec 2))
  (= 2 (inc 1)))