Template:SwitchClass
Uses Lua: |
Template used to choose a template according to the classes an item is an instance of, intended primarily for the template {{Item documentation}}
.
Takes a number of class/template pairs. The classes are the odd numbered arguments, the corresponding template names are the even numbered arguments.
Named arguments (both optional):
item
: the item identifier for the item we want to render with the template.default
: a template name used if no class match is found.
Each template is passed as first numbered argument the item
value if called.
The first matching class is used, so if there is more specific class involved in the keys, such as “beer” and “drink” as a beer is a drink, the “beer” class should come first.
Usage
[edit]Example using parameters human (Q5) => template:Q'; scholarly article (Q13442814) => Template:scholia
{{SwitchClass
|item=Q42
|Q5|Q'
|Q13442814|scholia
}}
With item Douglas Adams (Q42): Douglas Adams (Q42)
With item What is new for an old molecule? Systematic review and recommendations on the use of resveratrol (Q21089966):
Adding a a default case parameters human (Q5) => template:Q'; scholarly article (Q13442814) => Template:scholia; default: Template:Q
{{SwitchClass
|item=Q21089966
|Q5|Q'
|Q13442814|scholia
|default=Q
}}
With item What is new for an old molecule? Systematic review and recommendations on the use of resveratrol (Q21089966):
With item Universe (Q1):
See also
[edit]The above documentation is transcluded from Template:SwitchClass/doc (edit | history). Editors can experiment in this template's sandbox (create | mirror) and testcases (create) page. Please add categories to the /doc subpage. Subpages of this template. |