Template:Unit: Difference between revisions

From Eco - English Wiki
[unchecked revision][checked revision]
mNo edit summary
m (Add check to ensure at least one parameter.)
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly>{{#invoke:Sandbox/Demian/Unit|main}}</includeonly><noinclude>
<includeonly>{{#if:{{{1|}}} {{{2|}}}<!--
== Documentation ==
-->|{{#invoke:Unit|unit}}<!--
<pre>
-->|<span style="color:red">ERROR: No value given to Unit template!</span>|}}</includeonly><noinclude>
{{Template Sandbox/Demian/Unit}}
{{doc}}</noinclude>
</pre>
This template is using the following Modules:
*[[Module:Sandbox/Demian/Unit]]
 
== Example ==
Parts per million: "1 {{Template Sandbox/Demian/Unit|ppm}}".
 
List:
* Parts per million, numbered: "2 {{Template Sandbox/Demian/Unit|1=ppm}}"
* Meters: "3 {{Template Sandbox/Demian/Unit|m}}"
* Nanometers: "4 {{Template Sandbox/Demian/Unit|nm}}"
* megahertz "4 {{Template Sandbox/Demian/Unit|MHz}}" vs millihertz "4 {{Template Sandbox/Demian/Unit|mHz}}"
* square meter per second "10 {{Template Sandbox/Demian/Unit|m2/s}}" in two flavors "4 {{Template Sandbox/Demian/Unit|m2ps}}"
* "1 {{Template Sandbox/Demian/Unit|ug}}"
* "1 {{Template Sandbox/Demian/Unit|mohm}}"
* "1 {{Template Sandbox/Demian/Unit|Mohm}}"
* "1 {{Template Sandbox/Demian/Unit|kgm2}}"
* "1 {{Template Sandbox/Demian/Unit|jp(kmol)}}"
* "1 {{Template Sandbox/Demian/Unit|kib}}"
* "1 {{Template Sandbox/Demian/Unit|j/(kmol)}}"
 
Just text. Meters per second are "5 {{Template Sandbox/Demian/Unit|mps}}". Meters per second (short): "6 {{Template Sandbox/Demian/Unit|m/s}}". Empty: "7 {{Template Sandbox/Demian/Unit|}}". Finally only template: "8 {{Template Sandbox/Demian/Unit}}".
<templatedata>
{
"params": {},
"description": "Test template for development use.",
"format": "inline"
}
</templatedata></noinclude>

Latest revision as of 15:22, 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[Edit template data]

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[edit source]

  • 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[edit source]

Recognized units are defined and documented in Module:Unit/data.

Examples[edit source]

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. However, if the unit definition data is later updated to include the unit, it will begin using the tooltip correctly later.

Invalid units.
Code Result
{{Unit|99|things}} 99 things
{{Unit|something/other}} something/other
{{Unit|-2|players per hour}} -2 players per hour
{{Unit|7|lbft}} of torque 7 lbft of torque
{{Unit}} ERROR: No value given to Unit template!

Modules[edit source]

This template is using the following Modules:

Template:Doc/end