Template talk:If equal g

From Meta, a Wikimedia project coordination wiki
See also the more versatile Template:If.

This is a generalized version of Template:If equal, with the three parameters of the final template independent of the two test parameters.

Description of what it does:

If the 3rd and 4th parameter are equal than call the template specified by the 1st parameter, otherwise that by the 2nd. Each can have up to three unnamed parameters specified as the 5th, 6th and 7th parameter.

For each value of the 3rd parameter an auxiliary template callpar is needed, with the content {{{{{par }}}|{{{1}}}|{{{2}}}|{{{3}}}}} (currently available: list). Therefore, although the 3rd and 4th parameter are interchangeable in other regards, the order can be important: if expressions A and B are compared, choose the one with few possible values (or values for which there are already call-templates) as 3rd parameter.

*{{if equal g|t|t2||a|a|b|c}}
*{{if equal g|t|t2||||b|c}}
*{{if equal g|x0|death||v|[[November 2]], [[2004]]|[[Amsterdam]]|}}
*{{if equal g|x0|death|||||}}
*This is {{if equal g|x0|x1|User|{{NAMESPACE}}|not||}} the User namespace.

give:

  • Parameter 1 is "a", parameter 2 is "b"
  • start--end
  • Date of death: November 2, 2004, place of death: Amsterdam
  • This is not the User namespace.

More examples:

  • {{if equal g|2x|3x|{{NAMESPACE}}|Help|a||}} gives {{{{{Template_talk}}}|a||}}
  • {{if equal g|2x|3x|Help|{{NAMESPACE}}|a||}} gives aaa
  • {{if equal g|2x|3x|{{NAMESPACE}}|Template_talk|a||}} gives aa
  • {{if equal g|2x|3x|Template_talk|{{NAMESPACE}}|a||}} gives aaa

Note that {{NAMESPACE}} produces underscores for spaces, which are not considered equal by the template:

  • {{if equal g|2x|3x|{{NAMESPACE}}|Template talk|a||}} gives {{{{{Template_talk}}}|a||}}

See also w:Template:If equal g