Difference between revisions of "Template:List"
J McKalling (Talk | contribs) (debugging) |
J McKalling (Talk | contribs) (updated documentation) |
||
Line 17: | Line 17: | ||
}} | }} | ||
− | This template wraps | + | This template wraps a variable amount of (only) non-empty strings into an (un)ordered list. This is useful if the strings are yet to be determined by transclusion context, and only need to render list bullets if they are actually non-empty. The order of the strings will be honoured, in respect to their position number. Gaps are allowed and will be skipped. |
− | + | The list is terminated as soon as it detects an empty string, but this may be turned off for a specified range of strings. | |
==Parameters== | ==Parameters== | ||
− | Unlimited unnamed parameters, case sensitive, all default to not displayed. | + | Unlimited unnamed parameters are accepted, case sensitive, all default to not displayed. |
− | * '''numeric''': Whether to render a numeric (ordered) list instead (any value will do, defaults to false) | + | * '''numeric''': Whether to render a numeric (ordered) list instead of the default bulleted list (any value will do, defaults to false) |
− | * '''range''': The minimum number of elements in the list to | + | * '''range''': The minimum number of elements in the list to expect, before empty strings may terminate it (any digit greater than zero, defaults to zero) |
− | '''''Note''': The | + | '''''Note''': The '''range''' does not define the resulting size of the list, but only the size within which strings are allowed to be empty. Its value should not be greater than necessary, for best performance.'' |
==Syntax== | ==Syntax== | ||
Line 35: | Line 35: | ||
|string three | |string three | ||
|... | |... | ||
− | |string ten | + | |string ten-whatnot |
}}</nowiki> | }}</nowiki> | ||
==Examples== | ==Examples== | ||
− | When specifying only | + | When specifying only three strings: |
<nowiki>{{list | <nowiki>{{list | ||
|Ape | |Ape | ||
|Bear | |Bear | ||
− | | | + | |Cow |
− | + | ||
− | + | ||
}}</nowiki> | }}</nowiki> | ||
− | :<ul><li>Ape</li><li>Bear</li><li> | + | :<ul><li>Ape</li><li>Bear</li><li>Cow</li></ul> |
− | If only one string is specified: | + | If only one string is specified, it is still bulleted in a list <sup>(previously it wasn't)</sup>: |
<nowiki>{{list|only one string this time}}</nowiki> | <nowiki>{{list|only one string this time}}</nowiki> | ||
− | :only one string this time | + | :<ul><li>only one string this time</li></ul> |
− | If the numeric parameter is specified with a | + | If the numeric parameter is specified with a non-empty value: |
<nowiki>{{list|numeric=yes|only one string this time also}}</nowiki> | <nowiki>{{list|numeric=yes|only one string this time also}}</nowiki> | ||
<nowiki>{{list|numeric=yes | <nowiki>{{list|numeric=yes | ||
Line 63: | Line 61: | ||
|and another}}</nowiki> | |and another}}</nowiki> | ||
− | :only one string this time also | + | :<ol><li>only one string this time also</li></ol> |
:<ol><li>string one</li><li>and another</li></ol> | :<ol><li>string one</li><li>and another</li></ol> | ||
− | If the first string is empty or not specified, the list is terminated immediately and no list bullets will be displayed | + | If the first string is empty or not specified, the list is terminated immediately and no list bullets will be displayed: |
+ | <nowiki>{{list||second string is ignored}}</nowiki> | ||
+ | <nowiki>{{list|2=second string is ignored}}</nowiki> | ||
+ | |||
+ | |||
+ | Similarly, any other empty string will terminate the list as well, ignoring any further strings: | ||
+ | <nowiki>{{list|one|two|three||||seven}}</nowiki> | ||
+ | <nowiki>{{list|one|two|three|7=seven}}</nowiki> | ||
+ | |||
+ | :<ol><li>one</li><li>two</li><li>three</li></ol> | ||
+ | :<ol><li>one</li><li>two</li><li>three</li></ol> | ||
+ | |||
+ | |||
+ | But if '''range''' is specified and greater than zero, that many strings won't terminate the list even if they are empty: | ||
+ | <nowiki>{{list|range=6|one|two|three||||seven||nine}}</nowiki> | ||
+ | |||
+ | :<ol><li>one</li><li>two</li><li>three</li><li>seven</li></ol> | ||
</noinclude> | </noinclude> |
Revision as of 13:07, 7 June 2014
List | |
---|---|
Purpose |
Formatting [list all] |
Single tag |
Optional [list all] |
Multi-line |
Optional [list all] |
Protected |
No [list all] |
Game related |
No [list all] |
Categorization | |
Categories |
none [list all] |
Variables | |
Names |
One: [list all] |
|
|
Subpages |
This template wraps a variable amount of (only) non-empty strings into an (un)ordered list. This is useful if the strings are yet to be determined by transclusion context, and only need to render list bullets if they are actually non-empty. The order of the strings will be honoured, in respect to their position number. Gaps are allowed and will be skipped.
The list is terminated as soon as it detects an empty string, but this may be turned off for a specified range of strings.
Parameters
Unlimited unnamed parameters are accepted, case sensitive, all default to not displayed.
- numeric: Whether to render a numeric (ordered) list instead of the default bulleted list (any value will do, defaults to false)
- range: The minimum number of elements in the list to expect, before empty strings may terminate it (any digit greater than zero, defaults to zero)
Note: The range does not define the resulting size of the list, but only the size within which strings are allowed to be empty. Its value should not be greater than necessary, for best performance.
Syntax
{{list|numeric=yes |string one |string two |string three |... |string ten-whatnot }}
Examples
When specifying only three strings:
{{list |Ape |Bear |Cow }}
- Ape
- Bear
- Cow
If only one string is specified, it is still bulleted in a list (previously it wasn't):
{{list|only one string this time}}
- only one string this time
If the numeric parameter is specified with a non-empty value:
{{list|numeric=yes|only one string this time also}} {{list|numeric=yes |string one |and another}}
- only one string this time also
- string one
- and another
If the first string is empty or not specified, the list is terminated immediately and no list bullets will be displayed:
{{list||second string is ignored}} {{list|2=second string is ignored}}
Similarly, any other empty string will terminate the list as well, ignoring any further strings:
{{list|one|two|three||||seven}} {{list|one|two|three|7=seven}}
- one
- two
- three
- one
- two
- three
But if range is specified and greater than zero, that many strings won't terminate the list even if they are empty:
{{list|range=6|one|two|three||||seven||nine}}
- one
- two
- three
- seven