Template talk:Qif: Difference between revisions

From Hattrick
Jump to navigationJump to search
Duno7 (talk | contribs)
No edit summary
 
Duno7 (talk | contribs)
m fixed examples
Line 20: Line 20:
|
|
<pre>{{qif
<pre>{{qif
   |test={{boolne|foo|bar}}
   |test={{boolnot|true}}
   |then=true
   |then=true
   |else=false
   |else=false
Line 26: Line 26:
|
|
{{qif
{{qif
   |test={{boolne|foo|bar}}
   |test={{boolnot|true}}
   |then=true
   |then=true
   |else=false
   |else=false

Revision as of 15:49, 28 November 2005

Purpose and Function

  • This is an implementation of the "if ... then ... else" behaviour, to be used mostly in other Templates.
  • This function has undefined behaviour if parameter test or then is missing, or there are additional parameters defined. Parameter else is optional.
  • This is basically the same as the Wikipedia template [1], please check the discussion page on the wikipedia for more information.

Usage

{{qif
  |test=VARIABLE_OR_PARAMETER_TO_TEST
  |then=code if true or empty
  |else=code if true or empty
}}

Example

Code Result
{{qif
  |test={{boolnot|true}}
  |then=true
  |else=false
}}

false

{{qif
  |test={{booleq|foo|bar}}
  |then=true
  |else=false
}}

true

{{qif
  |test=
  |then=bar
}}
{{qif
  |test=foo
  |then=bar
}}

Comments

Ok, let's see if this works. It can be useful in some templates (for hiding empty fields, or similar) --duno7 15:24, 28 November 2005 (UTC)