Template:If elseif/doc
Jump to navigation
Jump to search
| File:Greek lc beta icon.svg | This template is rated as beta. It is considered ready for widespread use, but as it is still relatively new, it should be applied with some caution to ensure results are as expected. |
| File:Lua-Logo.svg | This template uses Lua: |
Tests a series of expressions, which are evaluated either as blank/noblank or, if |yesno= is set, using {{Yesno}}. Functionally equivalent to a if...elseif...elseif...else string butore efficient than nesting {{#if:}} parser functions from a post-expand include size standpoint.
Usage
[edit source]{{#if:test 1|value 1|{{#if:test 2|value 2|{{#if:...|default value}}}}}} can be replaced with
{{If elseif|test 1|value 1|test 2|value 2|...|default value}} or
{{If elseif|if1 = test 1|then1 = value 1|if2 = test 2|then2 = value 2|...|else = default value}}
Examples
[edit source]"{{If elseif|{{{empty1|}}}|1|{{{empty2|}}}|2|all empty}}"→ "all empty"
"{{If elseif|if1={{{empty1|}}}|then1=1|if2={{{notempty2|somevalue}}}|then2=2|else=all empty}}"→ "2"
"{{If elseif|{{#expr:1<0}}|1<0|{{#expr:4<0}}|4<0|{{#expr:-1<0}}|-1<0|{{#expr:-2<0}}|-2<0|None are true|yesno=true}}"→ "-1<0"- Note the use of
|yesno=true. Without it, the module returns "1<0" since #expr returns0when the statement is false, which is not blank.
- Note the use of