Template:Array/doc
More actions
This is the documentation page for Array. It contains usage information, categories, and other content not part of the original template page. | ||
|---|---|---|
| Main | Documentation | Usage |
Divides a string into a formatted list of substrings.
Syntax edit
- 1 — arrayString - the input string, each item separated by 2.
- 2 — separator - the character or substring to split on.
- 3 — format - the resulting format of each substring.
- 4 — join (optional) - separator between each element to join. Default no separator.
- {item} is replaced with the item.
- {newline} is replaced with a newline.
- {index} is replaced with the index.
- sort — (optional) set to 1 to sort the items in the array in ascending order, -1 for descending.
- dedupe — (optional) set to 1 to remove duplicate items from array.
- noTrim — (optional) set to 1 to not remove whitespace from items in the array.
- removeEmpty — (optional) set to 1 to remove empty items from array.
- sentence — (optional) set to 1 to display as sentence.
- sentence_join — (optional) join character. Default ,
- sentence_last — (optional) last item join word. Default and
- prefix — (optional) text added to start of result.
- suffix — (optional) text added to end of result.
- template — (optional) set to 1 to allow escaped template syntax for complex returns
- escape {{ as: ²{ or ^2{.
- escape }} as: }² or }^2.
- escape | as: ¦ or ¹.
- existLink — (optional) set to 1 to automatically link the resulting string if a page by the same name exists, only for simple lists.
Examples edit
{{Array|1,2,3,4,5|,|*''{item}''{newline} }} yields:
- 1
- 2
- 3
- 4
- 5
{{Array|1,2,2,2,3,4,5|,|*''{item}''{newline}|dedupe = 1}} yields:
- 1
- 2
- 3
- 4
- 5
{{Array|Dorjelang;Isaki;Rebella;Mobai;Mors|;|*{item}{newline}|sort = 1}} yields:
- Dorjelang
- Isaki
- Mobai
- Mors
- Rebella
{{Array|Dorjelang;Rebella;Frostia|;|[[{item}]]|XXX}} yields: DorjelangXXXRebellaXXXFrostia
{{Array
|Frostia;Yunguo;Frostia
|;
|[[{item}]]
|sentence = 1
|prefix = In Coziness Test, 
|suffix =  are available.
}}
yields: In Coziness Test, Frostia, Yunguo, and Frostia are available.
{{Array|a&&b&&c&&d&&e|&&|{index}: {item}|, }} yields: 1: a, 2: b, 3: c, 4: d, 5: e
{{Array|Broken Wood;Flamewood;Tree Sap|;|3 = {{Item|{item}|x = 50}}[[File:{item} Icon.png|30x30px|alt={item}|link={item}]][[File:{item} Icon.png|30x30px|alt={item}|link={item}]] [[{item}|{item}]] ×50}} yields:
{{Item|{item}|x = 50}}![]()
Broken Wood ×50{{Item|{item}|x = 50}}![]()
Flamewood ×50{{Item|{item}|x = 50}}![]()
Tree Sap ×50
{{Array
|Flamewood,Tree Sap,Broken Wood
|,
|3 = ²{#switch:{item}¦Flamewood¦Tree Sap¦=[[:Category:Uses {item}]]¦#default=invalid}²
|$$
|template = 1
}}
yields: Category:Uses Flamewood$$Category:Uses Tree Sap$$invalid
Template Data edit
Divides a string into a formatted list of substrings.
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| arrayString | 1 | The input string, each item separated by "separator" | String | required |
| separator | 2 | The character or substring to split on. | String | required |
| format | 3 | The resulting format of each substring. Must include {item}. Include "{newline}" for newline character or "{index}" for index of item.
| String | required |
| join | 4 | Separator between each element to join.
| String | optional |
| sort | sort | Set to 1 to sort the items in the array in ascending order, -1 for descending. | Number | optional |
| dedupe | dedupe | Set to 1 to remove duplicate items from array. | Boolean | optional |
| noTrim | noTrim | Set to 1 to not remove whitespace from items in the array. | Boolean | optional |
| removeEmpty | removeEmpty | Set to 1 to remove empty items from array. | Boolean | optional |
| sentence | sentence | Set to 1 to display as sentence. | Boolean | optional |
| sentence_join | sentence_join | Join text for sentence.
| String | optional |
| sentence_last | sentence_last | Last item join text for sentence.
| String | optional |
| prefix | prefix | Text added to start of result. | String | optional |
| suffix | suffix | Text added to end of result. | Template | optional |
| template | template | Set to 1 to allow escaped template syntax for complex returns. "²{" or "^2{" for "{{", "}²" or "}^2" for "}}", "¦" or "¹" for "|" | String | optional |