Template:Unit: Difference between revisions
[unchecked revision] | [unchecked revision] |
m (Improve documentation.) |
m (Use doc template.) Tag: Replaced |
||
Line 1: | Line 1: | ||
<includeonly>{{#invoke:Sandbox/Demian/Unit|unit}}</includeonly><noinclude> | <includeonly>{{#invoke:Sandbox/Demian/Unit|unit}}</includeonly><noinclude>{{doc}}</noinclude> | ||
{{ | |||
Revision as of 12:15, 25 February 2022
Add a tooltip to an abbreviation of a unit of measure showing the actual name of the unit.
Parameter | Description | Type | Status | |
---|---|---|---|---|
Number | number | Numerical value to format for display with the unit.
| Number | optional |
Unit abbreviation | abbr | Case sensitive abbreviation of a unit of measure. If the abbreviation contains a forward slash "/" it may be replaced with the character "p".
| String | optional |
Usage
- With a formatted number:
{{Unit|number|abbr}}
- If a number is specified, it is formatted with a space " " as a thousands separator and a period "." as the decimal separator.
- With unit abbreviation only:
{{Unit|abbr}}
New units
Recognized units are defined and documented in Module:Unit/data.
Examples
Code | Result |
---|---|
{{Unit|ppm}} |
Script error: No such module "Sandbox/Demian/Unit". |
{{Unit|1200|m}} |
Script error: No such module "Sandbox/Demian/Unit". |
{{Unit|1|m/s}} |
Script error: No such module "Sandbox/Demian/Unit". |
{{Unit|mps}} |
Script error: No such module "Sandbox/Demian/Unit". |
34 {{Unit|kg}} |
34 Script error: No such module "Sandbox/Demian/Unit". |
{{Unit|+2|degc}} |
Script error: No such module "Sandbox/Demian/Unit". |
Note that the abbreviation is case sensitive and if the unit contains special symbols they are displayed correctly:
Code | Result |
---|---|
{{Unit|-2,1|mHz}} |
Script error: No such module "Sandbox/Demian/Unit". |
{{Unit|-0.1|MHz}} |
Script error: No such module "Sandbox/Demian/Unit". |
{{Unit|0|m2}} |
Script error: No such module "Sandbox/Demian/Unit". |
{{Unit|+1|kohm}} |
Script error: No such module "Sandbox/Demian/Unit". |
{{Unit|852001,99|kWh}} |
Script error: No such module "Sandbox/Demian/Unit". |
4–8 {{Unit|um}} |
4–8 Script error: No such module "Sandbox/Demian/Unit". |
{{Unit|J/(Kmol)}} |
Script error: No such module "Sandbox/Demian/Unit". |
If a unit definition is not found, the abbreviation (or text) is returned unchanged. However, if the unit definition data is later updated to include the unit, it will begin using the tooltip correctly later.
Code | Result |
---|---|
{{Unit|99|things}} |
Script error: No such module "Sandbox/Demian/Unit". |
{{Unit|something/other}} |
Script error: No such module "Sandbox/Demian/Unit". |
{{Unit|-2|players per hour}} |
Script error: No such module "Sandbox/Demian/Unit". |
{{Unit|7|lbft}} of torque |
Script error: No such module "Sandbox/Demian/Unit". of torque |
{{Unit}} |
Script error: No such module "Sandbox/Demian/Unit". |
Modules
This template is using the following Modules: