{constants:group:format:delimiter}

Description

Lists every constant in a constant group, in priority order. A constant group is a named, reusable lookup table (the same store behind AA categories and select-box options); each row has a value and a human-readable name. The group argument is the group id; format chooses what to print for each row - value (the default) or name, or a template using the row aliases _#VALUE##_ and _#NAME###_; delimiter joins the results. With an empty delimiter (the default) the rows are concatenated with nothing between them. Two special delimiters build structured output: json returns a JSON array, jsonasoc a JSON object. An unknown or empty group yields an empty string. To read a single constant by its value use the constant command; to emit ready-made HTML option tags use options.

Parameters

group required default (none)

The constant group id to read. An unknown or empty group produces an empty result.

format optional default value

What to print for each constant: value (the default) or name, or a template containing the aliases _#VALUE##_ and _#NAME###_ which are replaced per row.

delimiter optional default (empty)

String placed between results. Empty by default (results are concatenated). The special values json and jsonasoc return a JSON array or object instead of a joined string.

Examples

test{constants:aa_doc_colors}
Expectedredgreenblue
Actualredgreenblue
With only a group, each constant value is printed and, because the delimiter is empty by default, the values run together with nothing between them.
test{constants:aa_doc_colors:name:, }
ExpectedRed, Green, Blue
ActualRed, Green, Blue
format=name prints the human-readable name of each constant; the third argument is the delimiter placed between them.
test{constants:aa_doc_colors:value:|}
Expectedred|green|blue
Actualred|green|blue
format=value is the same as leaving format empty - it prints the stored value of each constant.
test{constants:aa_doc_colors:_#VALUE##_=_#NAME###_:; }
Expectedred=Red; green=Green; blue=Blue
Actualred=Red; green=Green; blue=Blue
Any format other than value or name is a template: the aliases _#VALUE##_ and _#NAME###_ are replaced with each constant value and name in turn.
test{constants:aa_doc_colors:name:json}
Expected["Red","Green","Blue"]
Actual["Red","Green","Blue"]
The special delimiter json returns the results as a JSON array instead of a joined string. jsonasoc returns a JSON object built by splitting each result on the arrow ->.
test[{constants:no_such_group}]
Expected[]
Actual[]
An empty or unknown group id yields an empty string (shown here inside brackets so the empty result is visible).
test{count:{constants:aa_doc_colors::-}}
Expected3
Actual3
A common pattern - join the values with a dash and pass them to count to get the number of constants in the group.