Template:Comma

From Terraria Wiki
Jump to navigation Jump to search
This template is i18n-ready, which means it is easy to localize for different languages. Please see I18n & l10n for templates to learn more.
See Template:Comma/l10n for the localization of this template.
Important.svg
CAUTION: Terraria Wiki code is complex!!!
If you want to use this code on another wiki, wiki.gg staff are not able to assist you.
Please consider picking a different wiki to adapt code from, or making your own templates!
Remember that content on a wiki is more important than fancy formatting.
Template-info.svg Documentation The documentation below is transcluded from Template:Comma/doc. (edit | history)

Separates strings of text with commas. It uses Oxford commas in English.

Usage

This template is a dual-style template. It can be transcluded in two different ways with the exact same output.

Single-template style

{{ comma | <text 1> | <text 2> | ... | <text n> | or = y/yes | sep1 = <custom separator> | sep2 = <custom separator> | sep3 = <custom separator> }}

Unnamed parameters

Strings of text that will be separated by commas, can be continued nearly infinitely. Empty parameters will be ignored.

or

Changes the connector word between the last two strings of text from "and" (the default) to "or".

sep1, sep2, sep3

Custom separators to override the default ones. $sep2 is the separator if there are exactly two strings of text. $sep1 is the separator between all strings of text except the last two and $sep3 is the separator between the last two strings of text.

Parameter Default Example (default) Example (__)
sep1 , A, B, C, and D A__B__C, and D
sep2 and A and B A__B
sep3 , and A, B, C, and D A, B, C__D

Multi-template style

{{ comma/start | or = y/yes | sep1 = <custom separator> | sep2 = <custom separator> | sep3 = <custom separator> }}
{{ comma/item | <text 1> }}
{{ comma/item | <text 2> }}
...
{{ comma/item | <text n> }}
{{ comma/end | or = y/yes }}

See above for parameter descriptions. $or can be set either in {{comma/start}} or in {{comma/end}}, both are possible.

This multi-template style is useful when the number of strings is variable, i.e. unknown beforehand, and is often useful within the code of other templates, such as {{distinguish}}.

Examples

Code Result
{{comma|A}} A
{{comma|A|B}} A and B
{{comma|A|B|C}} A, B, and C
{{comma|A|B|C|D}} A, B, C, and D
{{comma|A||C|D}} A, C, and D
{{comma|A||C|||||H}} A, C, and H
{{comma|or=y|A}} A
{{comma|or=y|A|B}} A or B
{{comma|or=y|A|B|C}} A, B, or C
{{comma|or=y|A|B|C|D}} A, B, C, or D
{{comma|A|B|C|D|sep1=×|sep3=×...×}} A×B×C×...×D
{{comma|or=y|A|B|C|D|sep1=×|sep3=×...×}} A×B×C×...×D
{{comma/start}}{{comma/item|A}}{{comma/item|B}}{{comma/end}} A and B
{{comma/start}}{{comma/item|A}}{{comma/item|B}}{{comma/item|C}}{{comma/item|D}}{{comma/end}} A, B, C, and D
{{comma/start|or=y}}{{comma/item|A}}{{comma/item|B}}{{comma/item|C}}{{comma/end}} A, B, or C
{{comma/start}}{{comma/item|A}}{{comma/item|B}}{{comma/item|C}}{{comma/end|or=y}} A, B, or C
{{comma/start}}{{comma/end}}
{{comma/start|sep1=×|sep3=×...×}}{{comma/item|A}}{{comma/item|B}}{{comma/item|C}}{{comma/item|D}}{{comma/end}} A×B×C×...×D
{{#af_template:comma|{{#af_list:A|B|C|D}}}} A, B, C, and D
{{#af_template:comma|{{#af_object:or=y|1=A|2=B|3=C|4=D}}}} A, B, C, or D
{{#af_template:comma|{{#af_merge:{{#af_list:A|B|C|D}}|{{#af_object:or=y}}}}}} A, B, C, or D