Template:Ifnumber: Difference between revisions

From 118Wiki
Jump to navigation Jump to search
m (Switching documentation to inline code tags for styling)
(Replacing documentation with transclusion from subpage)
 
Line 1: Line 1:
<includeonly>{{#iferror: {{#expr: {{{1|}}}=0 }} | {{{3|}}} | {{{2|}}} }}</includeonly><noinclude>Checks if the first parameter results in a numeric value, for use in other templates. Copied from the [https://fr.wikisource.org/wiki/Mod%C3%A8le:Ifnumber French Wikisource] wiki.
<includeonly>{{#iferror: {{#expr: {{{1|}}}=0 }} | {{{3|}}} | {{{2|}}} }}</includeonly><noinclude>{{doc}}</noinclude>
 
Examples:
* <code><nowiki>{{ifnumber|3|yes|no}}</nowiki></code> -> {{ifnumber|3|yes|no}}
* <code><nowiki>{{ifnumber|This is not a number|yes|no}}</nowiki></code> -> {{ifnumber|This is not a number|yes|no}}
 
The other parameters are optional:
* <code><nowiki>{{ifnumber|3||no}}</nowiki></code> -> {{ifnumber|3||no}}
* <code><nowiki>{{ifnumber|3|yes}}</nowiki></code> -> {{ifnumber|3|yes}}
* <code><nowiki>{{ifnumber|This is not a number||no}}</nowiki></code> -> {{ifnumber|This is not a number||no}}
* <code><nowiki>{{ifnumber|This is not a number|yes}}</nowiki></code> -> {{ifnumber|This is not a number|yes}}
[[Category:Templates]]
</noinclude>

Latest revision as of 21:02, 29 June 2023

Template Documentation
Checks if the first parameter results in a numeric value, for use in other templates. Copied from the French Wikisource wiki.

Examples:

  • {{ifnumber|3|yes|no}} -> yes
  • {{ifnumber|This is not a number|yes|no}} -> no

The other parameters are optional:

  • {{ifnumber|3||no}} ->
  • {{ifnumber|3|yes}} -> yes
  • {{ifnumber|This is not a number||no}} -> no
  • {{ifnumber|This is not a number|yes}} ->

Template Data

Returns the second parameter if the first parameter is numeric, and the third parameter if it's not.

Template parameters

ParameterDescriptionTypeStatus
Value to check1

The value that is checked for whether or not it's numeric.

Linerequired
Output if numeric2

The returned value if the first parameter is numeric.

Contentsuggested
Output if not numeric3

The returned value if the first parameter is NOT numeric.

Contentsuggested