Template:Switch/doc

value shows one specific branch out of multiple possible branches, dependent on a given value. It requires MediaWiki version 1.6 or better.

Usage
where   is a parameter or a variable

If no   result is defined, the result if no value matches will be blank.


 * The variables to switch have some constraints because the value must be able to be used as a parameter name
 * Characters known not to work are:
 * There mustn't be any space between the pipe character and the first character.


 * There is no fall-through (if you look at the code, you know why)
 * The similar but less ingenious parser function #switch: is more flexible.

How "switch" works
It works by the principle that a parameter declaration can be defined by the value of another parameter.

When we access the parameter, we don't have the name hard coded, but we rely on the value of another parameter (in this case the parameter 1).

In its simplest form it is just like booleq/eq2 ), but to make it more user friendly and remove the risk trying to access parameter 1, the string case:  was added to the parameters to check for.

Also there is an additional parameter default that can be used if you want to have a default value (no other case value matches).

The resulting code is:

Sandbox
Yesterday was. Today is. Tomorrow will be.

Today is.

Today is the 28 day of the month.

Today is.

Source
The template is copied from Wikipedia:Template:Switch, and the documentation is copied, with modifications, from Wikipedia:Template:Switch/doc. Both are released under he GFDL.