Outputs the first parameter, followed by a comma if both the second and third parameters are present, or " and " if only the second parameter is present. This is useful in constructing lists so that each item can be output with the appropriate separator ready for the next item in the list.
Optionally, arbitrary text can be output if neither second nor third parameters are specified, that is, if the item is the last in the list. This is useful for adding terminal punctuation such as a full stop, without the need to do decide at a higher level template whether the item is the last.
This is an implementation template intended to be used by other templates; in an article, it is easier simply to write out the list longhand, but in a template this can be complicated if the number of items in the list is unknown.
An alternative way of constructing such a list is to output the separator before each next item in the list, but that still requires knowledge of whether another item is to follow (to decide between the comma and " and ", so the two implementations boil down to the same thing.
The positional parameters are the item in the list to be displayed, the item following it, and the item following that. Any or all the parameters may be missing; blank parameters are treated the same as empty parameters.
The named parameters are:
- after: The text to follow the final item. This might be a semicolon, for example. The default is to have no following text.
- and: The text to use where by default " and " is written. This may be useful if there is a preference for a comma before the "and", or where it makes sense to write it in a language other than English, for example.
- comma: The text to use between items except the last and one-before-last. If not specified, the default is ", ".
The test cases include a fuller set of examples.
This last example shows the intended use, where several invocations of the template, each shifted by one parameter, can be used to construct a list.
See also[सम्पादन गर्नुहोस्]