Extension:ArrayFunctions

The ArrayFunctions extension creates an additional set of pure, Parsoid-compatible parser functions that operate on arrays.

The extension works by using pure parser functions. Instead of manipulating some previously defined array, a pure parser function takes some arguments, performs some calculation, and returns the result. Arrays, and other data types, are passed around as opaque data types.

af_bool
This parser function casts a string to a boolean. This is useful for creating an array containing a boolean.

Parameters

 * value : string or boolean
 * The value to cast to a boolean.

Return values
Returns the casted boolean.

af_count
This parser functions counts the number of values in an array.

Parameters

 * array : array
 * The array to count.


 * recursive : boolean, default=false
 * Whether to count items recursively. Note that elements containing a list are also counted (see examples below).

Return values
The number of items in the array.

af_exists
This parser function checks whether the given key or index in an array exists.

Parameters

 * array : array
 * The array to check.


 * key : string or int
 * The key to check.

Return values
Returns true if  contains , false otherwise.

af_float
This parser function casts a string to a float. This is useful for creating an array containing a float.

Parameters

 * value : string or float
 * The value to cast to a float.

Return values
Returns the casted float.

af_foreach
This parser function provides a way to iterate over arrays.

Parameters

 * array : array
 * The array over which to iterate.


 * keyName : string, default=null
 * The name to use for the key.


 * valueName : string, default=null
 * The name to use for the value.


 * body : string
 * The body to return for each iteration.

Return values
Returns the resulting wikitext.

af_get
This parser function is used to index in an array.

Parameters

 * array : array
 * The array in which to index.


 * indices : string
 * The index. Multiple indices can be given to index nested arrays.

Return values
Returns the indexed value, or the empty string if the index does not exist.

af_int
This parser function casts a string to an integer. This is useful for creating an array containing an integer.

Parameters

 * value : string or int
 * The value to cast to an integer.

Return values
Returns the casted integer.

af_isarray
This parser function checks if the given value is an array.

Parameters

 * value : mixed
 * The value to check.

Return values
Returns true if  is an array, false otherwise.

af_join
This parser function recursively joins the items of an array together with a given separator.

Parameters

 * glue : string, default=""
 * The string used to join each item. This parameter recognises the following escape sequences:
 * for spaces
 * for newlines
 * for backslashes


 * array : array
 * The array to join.

Return values
Returns true if  is an array, false otherwise.

Installation
Not yet available.