Module:If elseif/doc: Difference between revisions
Jump to navigation
Jump to search
imported>Ahecht |
imported>Ahecht |
(No difference)
| |
Latest revision as of 17:12, 7 November 2025
| File:Greek lc beta icon.svg | This module 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. |
Implements {{If elseif}}. 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
{{#invoke:if elseif||test 1|value 1|test 2|value 2|...|default value}} or
{{#invoke:if elseif||if1 = test 1|then1 = value 1|if2 = test 2|then2 = value 2|...|else = default value}}
Examples
[edit source]"{{#invoke:if elseif||{{{empty1|}}}|1|{{{empty2|}}}|2|all empty}}"→ "all empty"
"{{#invoke:if elseif||if1={{{empty1|}}}|then1=1|if2={{{notempty2|somevalue}}}|then2=2|else=all empty}}"→ "2"
"{{#invoke: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