Open main menu

Difference between revisions of "Template:Switch"

119 bytes added ,  16:19, 5 March 2009
Use the template to calculate the examples results (should be fixed)
(Show the asked value when no default is available)
(Use the template to calculate the examples results (should be fixed))
Line 3: Line 3:
=Usage=
=Usage=
Use the "switch" argument to select which argument to show:
Use the "switch" argument to select which argument to show:
*<nowiki>{{{Switch|yes=yay|no=nay|switch=yes}}}</nowiki> will show "yay"
*<nowiki>{{Switch|yes=yay|no=nay|switch=yes}}</nowiki> shows "{{Switch|yes=yay|no=nay|switch=yes}}"
*<nowiki>{{{Switch|yes=yay|no=nay|switch=no}}}</nowiki> will show "nay"
*<nowiki>{{Switch|yes=yay|no=nay|switch=no}}</nowiki> shows "{{Switch|yes=yay|no=nay|switch=no}}"
If the specified option is unknown, the "switch" value will be shown:
If the specified option is unknown, the "switch" value will be shown:
*<nowiki>{{{Switch|yes=yay|no=nay|switch=err}}}</nowiki> will show "err"
*<nowiki>{{Switch|yes=yay|no=nay|switch=err}}</nowiki> shows "{{Switch|yes=yay|no=nay|switch=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> shows "{{Switch|yes=yay|no=nay|default=maybe|switch=err}}"
</noinclude>
</noinclude>
960

edits