Difference between revisions of "Template:Switch"

From ScummVM :: Wiki
Jump to navigation Jump to search
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>

Revision as of 15:59, 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}}} will show "yay"
  • {{{Switch|yes=yay|no=nay|switch=no}}} will show "nay"

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

  • {{{Switch|yes=yay|no=nay|switch=err}}} will show "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}}} will show "maybe"