Difference between revisions of "Template:Switch"

From ScummVM :: Wiki
Jump to navigation Jump to search
(New template to allow querying a named argument)
 
 
(27 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{ {{{arg}}} }}
<includeonly>{{{ {{{switch|}}}|{{IsEmpty|{{{default|}}}|empty={{{switch|}}}}}}}}</includeonly><noinclude>
This template allows you to conditionally show one of a predefined set of arguments, depending on another named argument.
=Usage=
Use the "switch" argument to select which argument to show:
*<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> shows "{{Switch|yes=yay|no=nay|switch=no}}"
If the specified option is unknown, the "switch" value will be shown:
*<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:
*<nowiki>{{Switch|yes=yay|no=nay|default=maybe|switch=err}}</nowiki> shows "{{Switch|yes=yay|no=nay|default=maybe|switch=err}}"
The "default" argument is ignored when it's empty:
*<nowiki>{{Switch|yes=yay|no=nay|default=|switch=err}}</nowiki> shows "{{Switch|yes=yay|no=nay|default=|switch=err}}"
</noinclude>

Latest revision as of 21:23, 5 March 2009

This template allows you to conditionally show one of a predefined set of arguments, depending on another named argument.

Usage

Use the "switch" argument to select which argument to show:

  • {{Switch|yes=yay|no=nay|switch=yes}} shows "yay"
  • {{Switch|yes=yay|no=nay|switch=no}} shows "nay"

If the specified option is unknown, the "switch" value will be shown:

  • {{Switch|yes=yay|no=nay|switch=err}} shows "err"

The "default" argument will be used when the "switch" value doesn't match any of the options or that's empty:

  • {{Switch|yes=yay|no=nay|default=maybe|switch=err}} shows "maybe"

The "default" argument is ignored when it's empty:

  • {{Switch|yes=yay|no=nay|default=|switch=err}} shows "err"