Difference between revisions of "Template:List"
From Twinsuniverse
J McKalling (Talk | contribs) m |
J McKalling (Talk | contribs) (added an ordered list feature and updated/fixed documentation) |
||
Line 1: | Line 1: | ||
<includeonly>{{ | <includeonly>{{ | ||
#ifexpr: ({{#if:{{{1|}}}|1|0}} + {{#if:{{{2|}}}|1|0}} + {{#if:{{{3|}}}|1|0}} + {{#if:{{{4|}}}|1|0}} + {{#if:{{{5|}}}|1|0}} + {{#if:{{{6|}}}|1|0}} + {{#if:{{{7|}}}|1|0}} + {{#if:{{{8|}}}|1|0}} + {{#if:{{{9|}}}|1|0}} + {{#if:{{{10|}}}|1|0}}) > 1 | #ifexpr: ({{#if:{{{1|}}}|1|0}} + {{#if:{{{2|}}}|1|0}} + {{#if:{{{3|}}}|1|0}} + {{#if:{{{4|}}}|1|0}} + {{#if:{{{5|}}}|1|0}} + {{#if:{{{6|}}}|1|0}} + {{#if:{{{7|}}}|1|0}} + {{#if:{{{8|}}}|1|0}} + {{#if:{{{9|}}}|1|0}} + {{#if:{{{10|}}}|1|0}}) > 1 | ||
− | |<ul>{{ | + | |<{{#ifeq: {{{numeric|}}}||ul|ol}}>{{ |
#if: {{{1|}}}| <li>{{{1}}}</li>}}{{ | #if: {{{1|}}}| <li>{{{1}}}</li>}}{{ | ||
#if: {{{2|}}}| <li>{{{2}}}</li>}}{{ | #if: {{{2|}}}| <li>{{{2}}}</li>}}{{ | ||
Line 11: | Line 11: | ||
#if: {{{8|}}}| <li>{{{8}}}</li>}}{{ | #if: {{{8|}}}| <li>{{{8}}}</li>}}{{ | ||
#if: {{{9|}}}| <li>{{{9}}}</li>}}{{ | #if: {{{9|}}}| <li>{{{9}}}</li>}}{{ | ||
− | #if:{{{10|}}}|<li>{{{10}}}</li>}}</ul> | + | #if:{{{10|}}}|<li>{{{10}}}</li>}}</{{#ifeq: {{{numeric|}}}||ul|ol}}> |
|{{{1|}}}{{{2|}}}{{{3|}}}{{{4|}}}{{{5|}}}{{{6|}}}{{{7|}}}{{{8|}}}{{{9|}}}{{{10|}}} | |{{{1|}}}{{{2|}}}{{{3|}}}{{{4|}}}{{{5|}}}{{{6|}}}{{{7|}}}{{{8|}}}{{{9|}}}{{{10|}}} | ||
}}</includeonly><noinclude> | }}</includeonly><noinclude> | ||
Line 20: | Line 20: | ||
==Parameters== | ==Parameters== | ||
Ten numbered parameters, no parameter name, case sensitive, all default to not displayed. | Ten numbered parameters, no parameter name, case sensitive, all default to not displayed. | ||
+ | * '''numeric''': whether to render a numeric list instead (defaults to dics bullets, any value will render numeric bullets) | ||
==Syntax== | ==Syntax== | ||
− | <nowiki>{{list | + | <nowiki>{{list|numeric=yes |
|string one | |string one | ||
|string two | |string two | ||
Line 40: | Line 41: | ||
}}</nowiki> | }}</nowiki> | ||
− | :<ul> | + | :<ul><li>Ape</li><li>Bear</li><li>Chihuahua</li><li>Donkey</li><li>Eel</li></ul> |
− | <li>Ape</li> | + | |
− | <li>Bear</li> | + | |
− | <li>Chihuahua</li> | + | |
− | <li>Donkey</li> | + | |
− | <li>Eel</li> | + | |
− | </ul> | + | |
Line 53: | Line 48: | ||
: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): | ||
+ | <nowiki>{{list|numeric=yes|only one string this time also}}</nowiki> | ||
+ | <nowiki>{{list|numeric=yes | ||
+ | |string one | ||
+ | |and another}}</nowiki> | ||
+ | |||
+ | :only one string this time also | ||
+ | :<ol><li>string one</li><li>and another</li></ol> | ||
Revision as of 23:10, 23 May 2014
This template wraps up to 10 nonempty strings into an unordered list. If only one string is not empty, it is returned as-is.
This is useful if the strings are yet unknown and only need to be wrapped if there are more than one not empty.
Parameters
Ten numbered parameters, no parameter name, case sensitive, all default to not displayed.
- numeric: whether to render a numeric list instead (defaults to dics bullets, any value will render numeric bullets)
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 all strings are empty or no string is specified, all are effectively omitted resulting in no display at all.