Difference between revisions of "Template:Format price/doc"
test>MSGJ m (→See also) |
test>Daviddwd |
||
| Line 44: | Line 44: | ||
[[Category:Finance templates]] | [[Category:Finance templates]] | ||
}}</includeonly> | }}</includeonly> | ||
| + | <templatedata> | ||
| + | { | ||
| + | "params": { | ||
| + | "1": { | ||
| + | "label": "value", | ||
| + | "description": "the value that will be formatted and displayed", | ||
| + | "example": "1,000", | ||
| + | "type": "number", | ||
| + | "required": true | ||
| + | }, | ||
| + | "2": { | ||
| + | "label": "digits", | ||
| + | "description": "sets the digit in which a value lower than one thousand must be rounded, defaulting to \"2\" (cents) if unspecified", | ||
| + | "type": "number", | ||
| + | "suggested": true | ||
| + | } | ||
| + | }, | ||
| + | "paramOrder": [ | ||
| + | "1", | ||
| + | "2" | ||
| + | ] | ||
| + | } | ||
| + | </templatedata> | ||
Revision as of 22:43, 2 December 2018
| This is a documentation subpage for Template:Format price. It contains usage information, categories and other content that is not part of the original template page. |
This template displays numbers typically representing prices in a pleasant way, ideally suited for articles. Numbers one thousand or greater are reduced down and rounded to a total of three digits followed by a multiplier text, and smaller numbers received separators and exactly two digits to represent cents, which does not always happen with the {{formatnum:}} magic word.
Contents
Usage
{{Format price|value|digits}}
Where:
- value: the value that will be formatted and displayed (required).
- digits: sets the digit in which a value lower than one thousand must be rounded, defaulting to "2" (cents) if unspecified.
Providing non-numeric parameters, failing to provide any parameter, or providing a negative value parameter, result all in a link to the NaN article. Despite its name, this template only handles the number-formatting, not any unit symbols – consider {{currency}} for that separate feature.
Examples
{{Format price|1.2}}= 1.20
{{Format price|456.789}}= 456.79
{{Format price|456.789|1}}= 456.80
{{Format price|456.789|0}}= 457
{{Format price|456.789|-2}}= 500
${{Format price|1234}}= $1.23 thousand
${{Format price|12345}}= $12.3 thousand
${{Format price|123456}}= $123 thousand
${{Format price|1000000}}= $1 million
¥{{Format price|98765432109876}}= ¥98.8 trillion
{{Format price|7.86178E+25}}atoms = 78.6 septillion atoms
Wrong
{{Format price}}= Format price error: cannot parse value "" (empty parameter)
{{Format price||0}}= Format price error: cannot parse value "" (empty first parameter)
{{Format price|-100}}= Format price error: cannot parse value "-100" (negative values are invalid)
{{Format price|xyz|A}}= Format price error: cannot parse value "xyz" (only numeric values are allowed)
{{Format price|1E+309}}= Format price error: cannot parse value "1E+309" (overflow)
See also
- {{Inflation}}
- {{Inflation/fn}}
No description.
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| value | 1 | the value that will be formatted and displayed
| Number | required |
| digits | 2 | sets the digit in which a value lower than one thousand must be rounded, defaulting to "2" (cents) if unspecified | Number | suggested |