Open main menu

Difference between revisions of "Template:Switch"

156 bytes added ,  15:59, 5 March 2009
Show the asked value when no default is available
m (Add general description)
(Show the asked value when no default is available)
Line 1: Line 1:
<includeonly>{{{ {{{switch|{{{default}}}}}} }}}</includeonly><noinclude>
<includeonly>{{{ {{{switch|{{{default}}}}}}|{{{switch}}} }}}</includeonly><noinclude>
This template allows you to conditionally show one of a predefined set of arguments, depending on another named argument.
This template allows you to conditionally show one of a predefined set of arguments, depending on another named argument.
=Usage=
=Usage=
Line 5: Line 5:
*<nowiki>{{{Switch|yes=yay|no=nay|switch=yes}}}</nowiki> will show "yay"
*<nowiki>{{{Switch|yes=yay|no=nay|switch=yes}}}</nowiki> will show "yay"
*<nowiki>{{{Switch|yes=yay|no=nay|switch=no}}}</nowiki> will show "nay"
*<nowiki>{{{Switch|yes=yay|no=nay|switch=no}}}</nowiki> will show "nay"
If the specified option is unknown, the "switch" value will be shown:
*<nowiki>{{{Switch|yes=yay|no=nay|switch=err}}}</nowiki> will show "err"
The "default" argument will be used when the "switch" value doesn't match any of the options or that's empty:
The "default" argument will be used when the "switch" value doesn't match any of the options or that's empty:
*<nowiki>{{{Switch|yes=yay|no=nay|default=maybe|switch=err}}}</nowiki> will show "maybe"
*<nowiki>{{{Switch|yes=yay|no=nay|default=maybe|switch=err}}}</nowiki> will show "maybe"
</noinclude>
</noinclude>
960

edits