(template options)
(template {:keys [=> default defaults throw? throw-on brackets] :as options}
values)
Replaces placeholders in template form (string or data structure) with values from supplied map.
Keys in map can be either keywords or symbols or strings.
String placeholder shoud be valid keyword name (without colon) in curly/square/angle braces (configurable) eg {name}, {user/name}, [user/name], <user/name>.
String placeholder can contain desired format separated with colon eg {order/date:%tD}.
Data placeholder should be valid keyword name (without colon) in angle braces represented as keyword eg :<name> or :<user/name>.
Data placeholders can't contain formatting.
First argument could be either template string, template data structure (if :=>
key is missing) or options map.
If first argument is a template data structure, options could be supplied as structure metadata.
The following options are supported:
:=>
- template form: string or data structure
:default
- sets a default for all missing values
:defaults
- a map with default values for certain keys
:throw?
or :throw
(when supplied as meta) - specifies if exception should be thrown in case of missing value and not having any defaults (defaults to false)
:throw-on
- a set with keys which should be always provided either through values map or defaults map
:brackets
- a keyword indicating types of brackets used for placeholders in template string. Valid options are:
:curly
(default) eg {user/name}:square
eg [user/name]:angle
eg <user/name>Replaces placeholders in template form (string or data structure) with values from supplied map. Keys in map can be either keywords or symbols or strings. String placeholder shoud be valid keyword name (without colon) in curly/square/angle braces (configurable) eg {name}, {user/name}, [user/name], <user/name>. String placeholder can contain desired format separated with colon eg {order/date:%tD}. Data placeholder should be valid keyword name (without colon) in angle braces represented as keyword eg :<name> or :<user/name>. Data placeholders can't contain formatting. First argument could be either template string, template data structure (if `:=>` key is missing) or options map. If first argument is a template data structure, options could be supplied as structure metadata. The following options are supported: `:=>` - template form: string or data structure `:default` - sets a default for all missing values `:defaults` - a map with default values for certain keys `:throw?` or `:throw` (when supplied as meta) - specifies if exception should be thrown in case of missing value and not having any defaults (defaults to false) `:throw-on` - a set with keys which should be always provided either through values map or defaults map `:brackets` - a keyword indicating types of brackets used for placeholders in template string. Valid options are: - `:curly` (default) eg {user/name} - `:square` eg [user/name] - `:angle` eg <user/name>
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close