Template talk:If equal
See also the generalized version Template:If equal g, with the three parameters of the final template independent of the two test parameters, and the simplified Template:Ine, where the criterion is being equal to the empty string, and the task for that case is producing nothing.
Description of what this template does:
If the 3rd and 4th parameter are equal then call the template specified by the 1st parameter, otherwise that by the 2nd. Each can have up to three unnamed parameters specified as the 4th, 5th and 6th parameter.
For each value of the 3rd parameter an auxiliary template callpar is needed, with the content {{{{{par }}}|{{{1}}}|{{{2}}}|{{{3}}}}} (currently available: list).
*{{if equal|t|t2||a|b|c}} *{{if equal|t|t2|||b|c}} *{{if equal|x0|death||[[November 2]], [[2004]]|[[Amsterdam]]|}} *>{{if equal|x0|death||||}}<
give:
- Parameter 1 is "a", parameter 2 is "b"
- start--end
- Date of death: November 2, 2004, place of death: Amsterdam
- ><
Some auxiliary templates that can be used:
- Template:X0 ("do zero times", blank)
- Template:X1 and the identical Template:P1 ("do one time", show first parameter)
- Template:P2 (show second parameter)
- Template:P3 (show third parameter)
Adaptation to more parameters
editAs mentioned, the two final templates can have up to three unnamed parameters. Adaptation to more involves adapting:
- template "if equal"
- template callpar
Typically, template:If equal is called from an infobox. Then, with regard to the number of these final parameters the following sequence should be non-increasing:
- The number of parameters supplied by the page calling the infobox
- The number of parameters supplied by the infobox calling "if equal"
- The number of parameters supplied by "if equal" calling callpar (currently 3, and for "if equal 6", calling call6par, 6)
- The number of parameters supplied by callpar (currently 3, and for call6, 6)
- The number of parameters used by the two final templates (in the examples above: 0, 1, and 2)
An exception is that if the infobox calls "if equal" with one or more parameters which are a constant or depend on a variable, but do not depend on a parameter of the infobox; in that case the page that calls the infobox does not have to supply that value. Also several parameter values with which the infobox calls "if equal" may be (or depend on) the same parameter of the infobox. In these cases the number of parameters supplied by the page calling the infobox can be less than the number of parameters supplied by the infobox calling "if equal".
See also
editSimilar templates:
- w:en:Template:If equal g
- w:en:Template:If defined call1
- w:en:Template:If defined call2
- w:en:Template:If defined call3
Usage of these templates:
- w:en:Template:Infobox CVG
- w:en:Template:Infobox Playboy Playmate
- w:en:Template:Peru region table
- w:fr:Template:Tableau région du Pérou
- w:en:Template:Seemain20
Another special template: