Difference between revisions of "Template:List"
J McKalling (Talk | contribs) (added infobox) |
J McKalling (Talk | contribs) (fixed: replaced rigid loop with flexible one, to keep it fast as possible (attempt)) |
||
Line 2: | Line 2: | ||
#if: {{{1|}}} | #if: {{{1|}}} | ||
|{{#ifeq: {{{2|}}}||{{{1|}}} | |{{#ifeq: {{{2|}}}||{{{1|}}} | ||
− | |<{{#ifeq: {{{numeric|false}}}|false|ul|ol}}>{{# | + | |<{{#ifeq: {{{numeric|false}}}|false|ul|ol}}>{{#vardefine: arg|1}}{{#while: |
− | + | |{{{ {{#var: arg}}|}}} | |
− | + | |<li>{{{ {{#var: arg}}}}}</li>{{#vardefine: arg|{{#expr:{{#var: arg}} + 1}}}}}}</{{#ifeq: {{{numeric|false}}}|false|ul|ol}}>}} | |
}}</includeonly><noinclude>{{Infobox Template | }}</includeonly><noinclude>{{Infobox Template | ||
|purpose=formatting | |purpose=formatting | ||
Line 16: | Line 16: | ||
}} | }} | ||
− | This template wraps up | + | This template wraps up non-empty strings into an (un)ordered list. The list will display the first string as-is if the second is empty, and will not display anything if the first is also empty. This is useful if the strings are yet unknown and only need to be wrapped if there are more than one not empty. |
If the arguments are specified by their position number however, then their position number will instead be taken into account for this mechanic. | If the arguments are specified by their position number however, then their position number will instead be taken into account for this mechanic. | ||
==Parameters== | ==Parameters== | ||
− | + | Unlimited unnamed parameters, 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 (any value will do, defaults to false) | ||
− | '''''Note''': The unnamed parameters | + | '''''Note''': The unnamed parameters should be specified in proper order if using their positional numbers, no gaps, because the first empty number will terminate the list.'' |
==Syntax== | ==Syntax== | ||
Line 65: | Line 65: | ||
− | If | + | If the first string is empty or not specified, no list bullets will be displayed. |
</noinclude> | </noinclude> |
Revision as of 18:17, 6 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 up non-empty strings into an (un)ordered list. The list will display the first string as-is if the second is empty, and will not display anything if the first is also empty. This is useful if the strings are yet unknown and only need to be wrapped if there are more than one not empty.
If the arguments are specified by their position number however, then their position number will instead be taken into account for this mechanic.
Parameters
Unlimited unnamed parameters, case sensitive, all default to not displayed.
- numeric: Whether to render a numeric (ordered) list instead (any value will do, defaults to false)
Note: The unnamed parameters should be specified in proper order if using their positional numbers, no gaps, because the first empty number will terminate the list.
Syntax
{{list|numeric=yes |string one |string two |string three |... |string ten }}
Examples
When specifying only five strings:
{{list |Ape |Bear |Chihuahua |Donkey |Eel }}
- Ape
- Bear
- Chihuahua
- Donkey
- Eel
If only one string is specified:
{{list|only one string this time}}
- only one string this time
If the numeric parameter is specified with a nonempty value (it is ignored when only one list item is specified):
{{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, no list bullets will be displayed.