View Source Cldr.List.Pattern (Cldr Lists v2.11.1)
A list pattern drives list formatting and it defines how to combine list elements at the begging, in the middle and at the end of a list. It also has a special pattern used when the list contains only two elements.
Summary
Functions
Creates a new list format.
Types
@type pattern() :: [non_neg_integer() | String.t(), ...]
Functions
Creates a new list format.
A list pattern consists of four string templates into which list elements are interpolated when formatting.
The four templates are:
:startused to format the first two list elements.:middleis used to format elements in the middle of the list.:endis used to format the last two elements in the list.:twois used to format a list if it contains only two elements.
Only the :start option is required. It
will be used as the default for any other
option that is not provided.
Arguments
optionsis a keyword list of options.
Options
:startis a pattern template as a string. This option is required.:middleis a pattern template as a string.:endis a pattern template as a string.:twois a pattern template as a string.
Returns
{:ok, pattern} or
{:error, reason}
Pattern template
A pattern template is a string that contains
two placeholders denoted by {0} and {1}.
Example
iex> Cldr.List.Pattern.new(
...> start: "{0}, {1}"),
...> middle: "{0}, {1}"),
...> end: "{0} and {1}"),
...> two: "{0} and {1}")
...> )
{:ok, _pattern}