Liking cljdoc? Tell your friends :D

active.data.translate.formatter

A formatter is a function [resolve] => translator, which create a translator, potentially based on other translators for a realm returned by the resolve function.

This namespace contains a collection of some standard formatters and utilities to build others.

A formatter is a function [resolve] => translator, which create a translator,
potentially based on other translators for a realm returned by the resolve function.

This namespace contains a collection of some standard formatters and utilities to build others.
raw docstring

constantsclj/s

(constants intern-extern-map)
(constants intern-extern-map external-realm)

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

Usage:

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

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

identityclj/s

(identity realm)

Returns an identity formatter for the given realm. The formatter throws if the external value is not contained in the realm.

Returns an identity formatter for the given realm. The formatter
throws if the external value is not contained in the realm.
raw 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])
```
raw docstring

simpleclj/s

(simple translator)

A simple (non recursive) formatter.

A simple (non recursive) formatter.
raw docstring

tagged-union-mapclj/s

(tagged-union-map tag-key content-key tag-realm-map)

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

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.

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>}
```
raw docstring

tagged-union-tupleclj/s

(tagged-union-tuple tag-realm-map)

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

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.

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>]
```
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close