Template:SPLIT
Template documentationedit documentation
Use this template to split the value of a template parameter into multiple values and process them individually.
Important! If the given value contains at least one semicolon, then it will be split by semicolon. Else, it will be split by commas.
Important! Use the second parameter to specify a wikitext pattern to process each individual value, where the special character '@' will be replaced by the value. The wikitext pattern must be wrapped with nowiki tags to prevent premature expansion of the wikitext (see examples below).
Examples
[edit source]| Input | Output | Description |
|---|---|---|
{{SPLIT}}
|
Nothing changes | |
{{SPLIT|}}
|
Nothing changes | |
{{SPLIT| }}
|
Nothing changes | |
{{SPLIT|a}}
|
a | Nothing changes |
{{SPLIT|a, b, c}}
|
a, b, c | Nothing changes |
{{SPLIT|a; b; c}}
|
a; b; c | Nothing changes |
{{SPLIT|a,b,c}}
|
a, b, c | Spacing is normalized |
{{SPLIT|a, b, c|<nowiki>[[@]]</nowiki>}}
|
a, b, c | Values are wikilinked |
{{SPLIT|a; b, c|<nowiki>[[@]]</nowiki>}}
|
a; b, c | Values are split by semicolon and wikilinked |
{{SPLIT|a, b, c|<nowiki>{{Search|@}}</nowiki>}}
|
a, b, c | Values are sent through a template |
{{SPLIT|a, b, c|<nowiki>[[@]]</nowiki>|<br>}}
|
a b c |
Values are wikilinked and rejoined with line breaks |
{{SPLIT|a, b, c|<nowiki>[[@]][[Category:@]]</nowiki>}}
|
a, b, c | Values are wikilinked and also used to categorize |
See also
[edit source]- mw:Extension:Page Forms/Page Forms and templates##arraymap - Inspiration for this template