Template:Unit/doc: Difference between revisions

From Eco - English Wiki
[unchecked revision][unchecked revision]
m (Add to "Formatting templates" category.)
m (Add numbers to some examples.)
Line 3: Line 3:
{
{
"params": {
"params": {
"number": {
"label": "Number",
"type": "number",
"description": "Numerical value to format for display with the unit.",
"example": "2, -2, 3.45"
},
"abbr": {
"abbr": {
"label": "Unit abbreviation",
"label": "Unit abbreviation",
"description": "Case sensitive abbreviation of a unit of measure. If the abbreviation contains a forward slash \"/\" it may be replaced with the character \"p\".",
"description": "Case sensitive abbreviation of a unit of measure. If the abbreviation contains a forward slash \"/\" it may be replaced with the character \"p\".",
"example": "m/s, mps, GHz, ppm, kg, m2, kWh",
"example": "m/s, mps, GHz, ppm, kg, m2, kWh",
"type": "string",
"type": "string"
"required": true
}
}
},
},
Line 14: Line 19:
"format": "inline",
"format": "inline",
"paramOrder": [
"paramOrder": [
"number",
"abbr"
"abbr"
]
]
Line 20: Line 26:


== Usage ==
== Usage ==
{{tlx|Unit|''abbr''}}
* With a formatted number: {{tlx|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: {{tlx|Unit|''abbr''}}


== New units ==
== New units ==
Line 33: Line 41:
| {{tlx|Unit|ppm}} || {{Unit|ppm}}
| {{tlx|Unit|ppm}} || {{Unit|ppm}}
|-
|-
| {{tlx|Unit|m}} || {{Unit|m}}
| {{tlx|Unit|1200|m}} || {{Unit|1200|m}}
|-
|-
| {{tlx|Unit|m/s}} || {{Unit|m/s}}
| {{tlx|Unit|1|m/s}} || {{Unit|1|m/s}}
|-
|-
| {{tlx|Unit|mps}} || {{Unit|mps}}
| {{tlx|Unit|mps}} || {{Unit|mps}}
|-
|-
| {{tlx|Unit|kg}} || {{Unit|kg}}
| 34 {{tlx|Unit|kg}} || 34 {{Unit|kg}}
|-
|-
| {{tlx|Unit|degc}} || {{Unit|degc}}
| {{tlx|Unit|+2|degc}} || {{Unit|+2|degc}}
|}
|}


Line 50: Line 58:
! Code !! Result
! Code !! Result
|-
|-
| {{tlx|Unit|mHz}} || {{Unit|mHz}}
| {{tlx|Unit|-2,1|mHz}} || {{Unit|-2,1|mHz}}
|-
|-
| {{tlx|Unit|MHz}} || {{Unit|MHz}}
| {{tlx|Unit|-0.1||MHz}} || {{Unit|-0.1|MHz}}
|-
|-
| {{tlx|Unit|m2}} || {{Unit|m2}}
| {{tlx|Unit|0|m2}} || {{Unit|0|m2}}
|-
|-
| {{tlx|Unit|kohm}} || {{Unit|kohm}}
| {{tlx|Unit|+1|kohm}} || {{Unit|+1|kohm}}
|-
|-
| {{tlx|Unit|kWh}} || {{Unit|kWh}}
| {{tlx|Unit|852001,99|kWh}} || {{Unit|852001,99|kWh}}
|-
|-
| {{tlx|Unit|um}} || {{Unit|um}}
| 4–8 {{tlx|Unit|um}} || 4–8 {{Unit|um}}
|-
|-
| {{tlx|Unit|J/(Kmol)}} || {{Unit|J/(Kmol)}}
| {{tlx|Unit|J/(Kmol)}} || {{Unit|J/(Kmol)}}
Line 76: Line 84:
|-
|-
| {{tlx|Unit|players per hour}} || {{Unit|players per hour}}
| {{tlx|Unit|players per hour}} || {{Unit|players per hour}}
|-
| {{tlx|Unit}} || {{Unit}}
|}
|}



Revision as of 15:20, 27 February 2022

Template:Doc/start

Add a tooltip to an abbreviation of a unit of measure showing the actual name of the unit.

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Numbernumber

Numerical value to format for display with the unit.

Example
2, -2, 3.45
Numberoptional
Unit abbreviationabbr

Case sensitive abbreviation of a unit of measure. If the abbreviation contains a forward slash "/" it may be replaced with the character "p".

Example
m/s, mps, GHz, ppm, kg, m2, kWh
Stringoptional

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

Commonly used units.
Code Result
{{Unit|ppm}} ppm
{{Unit|1200|m}} 1 200 m
{{Unit|1|m/s}} 1 m/s
{{Unit|mps}} m/s
34 {{Unit|kg}} 34 kg
{{Unit|+2|degc}} +2 °C

Note that the abbreviation is case sensitive and if the unit contains special symbols they are displayed correctly:

Various units.
Code Result
{{Unit|-2,1|mHz}} -2.1 mHz
{{Unit|-0.1|MHz}} -0.1 MHz
{{Unit|0|m2}} 0 m2
{{Unit|+1|kohm}} +1
{{Unit|852001,99|kWh}} 852 001.99 kW⋅h
4–8 {{Unit|um}} 4–8 μm
{{Unit|J/(Kmol)}} J/(K⋅mol)

If a unit definition is not found, the abbreviation (or text) is returned unchanged.

Invalid units.
Code Result
{{Unit|things}} things
{{Unit|something/other}} something/other
{{Unit|players per hour}} players per hour
{{Unit}} ERROR: No value given to Unit template!

Modules

This template is using the following Modules:

Template:Doc/end