Template:Join/doc
From Pittsburgh Streets
The {{join}} template joins strings with a specified separator. If the separator is not specified, the strings will be separated by a comma and a space.
Parameters
Parameter | Description |
---|---|
sep | The separator to insert between the strings being joined. The default is a comma and a space (,{{space}} ). Because of MediaWiki parser antics, leading and trailing spaces should be specified as {{space}} ; leading colons and semicolons should be specified as {{colon}} and {{;}} , respectively.
|
penult | The separator to use immediately before the last string when at least two strings are being joined. If penult is not specified, then sep is used.
|
two-sep | The separator to use when exactly two strings are being joined. This overrules penult in this case. If two-sep is not specified, then penult is used; if penult is also not specified, then sep is used.
|
Usage examples
Basic usage
{{join|one|two|three}}
→ one, two, three{{join|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty}}
→ one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen, twenty{{join|one||three||five}}
→ one, three, five{{join||two||four||six}}
→ two, four, six{{join}}
→
Specifying a separator
{{join|sep={{colon}}{{space}}|one|two|three}}
→ one: two: three
Using two-sep
{{join|sep={{;}}{{space}}|two-sep=,{{space}}|one}}
→ one{{join|sep={{;}}{{space}}|two-sep=,{{space}}|one|two}}
→ one, two{{join|sep={{;}}{{space}}|two-sep=,{{space}}|one|two|three}}
→ one; two; three{{join|sep={{;}}{{space}}|two-sep=,{{space}}|||three}}
→ three{{join|sep={{;}}{{space}}|two-sep=,{{space}}|||three||five}}
→ three, five{{join|sep={{;}}{{space}}|two-sep=,{{space}}|||three||five||||nine}}
→ three; five; nine
Using penult
{{join|penult={{space}}and{{space}}|one}}
→ one{{join|penult={{space}}and{{space}}|one|two}}
→ one and two{{join|penult={{space}}and{{space}}|one|two|three}}
→ one, two and three{{join|penult={{space}}and{{space}}||||four}}
→ four{{join|penult={{space}}and{{space}}||||four||six}}
→ four and six{{join|penult={{space}}and{{space}}||||four||six||||ten}}
→ four, six and ten
Using penult
and two-sep
{{join|penult=, and{{space}}|two-sep={{space}}and{{space}}|one}}
→ one{{join|penult=, and{{space}}|two-sep={{space}}and{{space}}|one|two}}
→ one and two{{join|penult=, and{{space}}|two-sep={{space}}and{{space}}|one|two|three}}
→ one, two, and three{{join|penult=, and{{space}}|two-sep={{space}}and{{space}}|||||five}}
→ five{{join|penult=, and{{space}}|two-sep={{space}}and{{space}}|||||five|||eight}}
→ five and eight{{join|penult=, and{{space}}|two-sep={{space}}and{{space}}|||||five|||eight|||eleven}}
→ five, eight, and eleven