Difference between revisions of "Template:If"
Jump to navigation
Jump to search
Zachary Yan (talk | contribs) (Created page with "{{{else{{{test|}}}|{{{test{{{test|}}}|{{{then|}}}}}}}}}<noinclude>#if replacement. Usage:<pre>{{if |test=VARIABLE_OR_PARAMETER_TO_TEST |then=code if 'test' is not empty ...") |
Kevin Wang (talk | contribs) |
||
Line 1: | Line 1: | ||
− | {{{else{{{test|}}}|{{{test{{{test|}}}|{{{then|}}}}}}}}}<noinclude>#if | + | {{{else{{{test|}}}|{{{test{{{test|}}}|{{{then|}}}}}}}}} |
+ | |||
+ | <noinclude> | ||
+ | Replacement for #if. | ||
Usage:<pre>{{if | Usage:<pre>{{if | ||
Line 8: | Line 11: | ||
Parameter else is optional. | Parameter else is optional. | ||
+ | |||
+ | Examples: | ||
+ | <pre> | ||
+ | {{if|test=x|then=y|else=z}} - x is not null, so return y | ||
+ | {{if|test= |then=y|else=z}} - x is null, so return z | ||
+ | {{if|test= |then=y}} - x is null and no else is defined, so don't return anything | ||
+ | </pre> | ||
+ | |||
+ | {{if|test=x|then=y|else=z}} | ||
+ | {{if|test= |then=y|else=z}} | ||
+ | {{if|test= |then=y}} | ||
+ | |||
+ | </noinclude> |
Revision as of 11:26, 18 December 2020
Replacement for #if.
Usage:
{{if |test=VARIABLE_OR_PARAMETER_TO_TEST |then=code if 'test' is not empty |else=code if 'test' is empty }}
Parameter else is optional.
Examples:
{{if|test=x|then=y|else=z}} - x is not null, so return y {{if|test= |then=y|else=z}} - x is null, so return z {{if|test= |then=y}} - x is null and no else is defined, so don't return anything
y
z