Template:Iszero/doc
Appearance
This is a documentation subpage for Template:Iszero It contains usage information, categories and other content that is not part of the original template page. |
{{iszero}} returns the passed value if it evaluates as non-zero. If it is zero, by default the template returns nothing, or it can return any other value you specify. Blank inputs are treated as zeros by default, but that can be overridden.
Tip: | Non-numeric text generally will evaluate as non-zero, so you may want to pass the input value through {{isnumeric}} first (see examples 12 and 14) and treat non-numeric text as a blank. |
---|
Usage
[edit source]Recognizes the following parameters
- The value to check; required
blank=
— To have blank values not be treated as zero, set this to any non-zero value you want returned; optionalwhenzero=
— Set to the value you want returned if the input value evaluates to zero; optional (defaults to blank)whenblank=
— Set to the value you want returned if the input value is blank; optional (defaults to blank)
Examples
[edit source]{{iszero}}
→ Blank{{iszero|0}}
→ Zero{{iszero|3}}
→ Default{{iszero|0|whenzero=Zero|whenblank=Blank}}
→ Zero{{iszero|whenzero=Zero|whenblank=Blank}}
→ Blank{{iszero||whenzero=Zero|whenblank=Blank}}
→ Blank{{iszero|blank=1|whenzero=Zero|whenblank=Blank}}
→ Blank{{iszero||blank=1|whenzero=Zero|whenblank=Blank}}
→ Blank{{iszero|0|blank=1|whenzero=Zero|whenblank=Blank}}
→ Zero{{iszero|3|blank=1|whenzero=Zero|whenblank=Blank}}
→ Default{{iszero|Some text|blank=1|whenzero=Zero|whenblank=Blank}}
→ Default{{iszero|{{isnumeric|Some text}}|blank=1|whenzero=Zero|whenblank=Blank}}
→ Blank{{iszero|Some text|blank=0|whenzero=Zero|whenblank=Blank}}
→ Default{{iszero|{{isnumeric|Some text}}|blank=0|whenzero=Zero|whenblank=Blank}}
→ Blank