Template:SwitchClass

From Wikidata
Jump to navigation Jump to search
Documentation icon Template documentation[view · edit · history · purge ]

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)  View with Reasonator View with SQID

With item What is new for an old molecule? Systematic review and recommendations on the use of resveratrol (Q21089966): View profile on Scholia

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): View profile on Scholia

With item Universe (Q1):

Universe (Q1)

See also

[edit]