Category:If Templates

From Wikipedia

These are templates used for "if-then-else" types of queries.

When adding a Category to a template, remember to wrap it within <noinclude> </noinclude>. Otherwise all articles using the template will acquire the category. If you add <noinclude>...</noinclude> at the end of the template, please make sure that the opening <noinclude> starts on the same line as the last char of the template code. Experiments revealed that some templates became seriously defunct when that rule was violated.

Be careful with them! They are tricky to manipulate and shouldn't be edited recklessly. When using those templates, you should add {{esoteric}} to the <noinclude> </noinclude> of your template.

Usage[ᎦᏁᏟᏴᏓ ᎰᏪᎸᎦ]

{{qif
  |test=test
  |then=code if test is true
  |else=code if test is false
}}
Result: "Template:Qif"
{{switch
  |data
  |case: data=yes
  |default=no
}}
Result: "yes"
{{if defined
  |test=test
  |call=show1
  |1=1=foo
}}
Result: "Template:If defined"
{{unless defined
  |test=
  |call=show1
  |1=1=foo
}}
Result: "Template:Unless defined"

test is a value, true if defined, false otherwise, a parameter is used as a test as {{{param|}}}, the ending | is important so it can default to false. For more complex test, use the boolean templates defined below.

Furthermore, you should always define index to arguments for those templates, otherwise you might get strange results, if you have a parameter with a = embeded (for example url's).

Booleans[ᎦᏁᏟᏴᏓ ᎰᏪᎸᎦ]

To make using {{if}} easier, there are some boolean templates that can be used as first argument to if.

See Category:Boolean Templates for full details: In all this templates, argument is true if defined, false otherwise, it return 1 if true, undef otherwise.

{{booland}}
if A and B is true, return true.
{{boolor}}
if A or B is true, return true.
{{boolxor}}
if A or B is true, but not A and B, return true.
{{boolnxor}}
if A and B is false or A and B is true, return true.
{{boolnand}}
if A or B is false, return true.
{{boolnor}}
if A and B is false, return true.
{{boolnot}}
if A is false, return true, else return false.

Equals operators[ᎦᏁᏟᏴᏓ ᎰᏪᎸᎦ]

{{booleq}}
Returns true if A and B equals.
{{boolne}}
Returns false if A and B equals.

Pages in category "If Templates"

This category contains only the following page.