Liking cljdoc? Tell your friends :D

active.data.translate.formatter

A collection of some standard formatters that can be used to build formats.

A collection of some standard formatters that can be used to build formats.
raw docstring

constantsclj/s

(constants intern-extern-map & {fallback :fallback})

Formatter that translates fixed values, like in a realm/enum

Options are:

:fallback: a function called on unknown values. If not given, a format-error is thrown in those case.

Usage:

(constants {:foo "foo"})
Formatter that translates fixed values, like in a realm/enum

Options are:

`:fallback`: a function called on unknown values. If not given, a
format-error is thrown in those case.

Usage:
```
(constants {:foo "foo"})
```
sourceraw docstring

idclj/s

Identity formatter, when no translation is needed for a realm.

Identity formatter, when no translation is needed for a realm.
sourceraw docstring

record-mapclj/s

(record-map record spec & {strict? :strict? defaults :defaults})

Formatter to represent a record as a map with explicit keys.

Options are:

:strict?: if set then a format-error is thrown when the map contains unknown keys. By default they are ignored.

:defaults: a map of defaults for record fields. If none is given then a format-error is thrown if the parsed map does not contain a defined key.

Usage:

(record-map MyRecord
            {my-rec-foo :foo 
             my-rec-bar :bar}
            :defaults {my-rec-foo "value"})

or

(record-map MyRecord [:foo :bar])
Formatter to represent a record as a map with explicit keys.

Options are:

`:strict?`: if set then a format-error is thrown when the map contains
unknown keys. By default they are ignored.

`:defaults`: a map of defaults for record fields. If none is given then a
format-error is thrown if the parsed map does not contain a defined key.

Usage:
```
(record-map MyRecord
            {my-rec-foo :foo 
             my-rec-bar :bar}
            :defaults {my-rec-foo "value"})
```

or

```
(record-map MyRecord [:foo :bar])
```
sourceraw docstring

simpleclj/s

(simple translator)

A simple (non recursive) formatter directly based on a translator lens.

A simple (non recursive) formatter directly based on a translator lens.
sourceraw docstring

tagged-union-mapclj/s

(tagged-union-map tag-key content-key tag-realm-map & {fallback :fallback})

Formatter that distinguishes between different realms depending on a tag value in a map.

Options are:

:fallback: a function taking a tag and value, whose return value is used when the translated value has an unknown tag. If not given, a format-error is thrown.

For example:

(tagged-union-map :tag :value {"foo" foo-realm})

returns a formatter that can be used for a union realm that contains foo-realm, where the formatted values look like:

{:tag "foo" :value <foo-value>}
Formatter that distinguishes between different realms depending on a
 tag value in a map.

Options are:

`:fallback`: a function taking a tag and value, whose return value
is used when the translated value has an unknown tag. If not given,
a format-error is thrown.

For example:
```
(tagged-union-map :tag :value {"foo" foo-realm})
```
returns a formatter that can be used for a union realm that contains `foo-realm`, where the formatted values look like:
```
{:tag "foo" :value <foo-value>}
```
sourceraw docstring

tagged-union-tupleclj/s

(tagged-union-tuple tag-realm-map & {fallback :fallback})

Formatter that distinguishes between different realms depending on the value of the first part of a tuple.

Options are:

:fallback: a function taking a tag and value, whose return value is used when the translated value has an unknown tag. If not given, a format-error is thrown.

For example:

(tagged-union-tuple {"foo" foo-realm})

returns a formatter that can be used for a union realm that contains foo-realm, where the formatted values look like:

["foo" <foo-value>]
Formatter that distinguishes between different realms depending on the
 value of the first part of a tuple.

Options are:

`:fallback`: a function taking a tag and value, whose return value
is used when the translated value has an unknown tag. If not given,
a format-error is thrown.

For example:
```
(tagged-union-tuple {"foo" foo-realm})
```
returns a formatter that can be used for a union realm that contains `foo-realm`, where the formatted values look like:
```
["foo" <foo-value>]
```
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close