Template:Convert/doc

From SPCodex, The Smashing Pumpkins wiki

Template {{convert}} calculates a measurement value (number × unit) into the same measurement by a different unit, and then presents the results, formatted. The complete list of unit symbols recognized by the template is here.

For example:

{{convert|2|km|mi}} → 2 kilometres (1.2 mi) (km entered, converted into miles)
{{convert|7|mi|km}} → 7 miles (11 km) (mi entered, converted into km)

Numbers can be rounded, units can be abbreviated into symbols:

{{convert|2|km|mi|2|abbr=on}} → 2 km (1.24 mi)
{{convert|7|mi|km|2|abbr=on}} → 7 mi (11.27 km)

Value ranges can be entered using |to|... or |-|...:

{{convert|2|to|5|km|mi}} → 2 to 5 kilometres (1.2 to 3.1 mi)
{{convert|2|-|5|km|mi}} → 2–5 kilometres (1.2–3.1 mi)

Combined effect example:

{{convert|2|-|5|km|mi|2|abbr=on}} → 2–5 km (1.24–3.11 mi)
{{convert|2|and|5|km|mi|sigfig=3|abbr=off}} → 2 and 5 kilometres (1.24 and 3.11 miles)

TemplateData[edit source]

Converts measurements to other units.

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Value1

The value to convert.

Numberrequired
From unit2

The unit for the provided value.

Suggested values
km2 m2 cm2 mm2 ha sqmi acre sqyd sqft sqin km m cm mm mi yd ft in kg g mg lb oz m/s km/h mph K C F m3 cm3 mm3 L mL cuft cuin U.S.gal U.S.oz psi mpgU.S. $/lb $/kg
Example
km
Stringrequired
To units3

The units to convert into. Separate units by a space for multiple outputs. In an output unit, use + for a multiplication space.

Suggested values
km2 m2 cm2 mm2 ha sqmi acre sqyd sqft sqin km m cm mm mi yd ft in kg g mg lb oz m/s km/h mph K C F m3 cm3 mm3 L mL cuft cuin U.S.gal U.S.oz psi mpgU.S. $/lb $/kg
Example
mi nmi
Stringsuggested
Precision or suffix4

Significant digits after decimal dot or, if negative, exponent of ten.

Numberoptional
Link unitslk

Indication of what units to apply wikilinks to. Use “on” for all, “in” for the input unit, “out” for the output units, or “off” for none of the units. For more fine-grained control over which units to link, use the template multiple times.

Suggested values
in out on off
Default
off
Example
on
Stringoptional
Abbreviationabbr

Display for the units: “on” to display all units using their unit symbols, “off” to display all units in full words, “in” to display the unit symbol for the input unit, “out” to display the unit symbols for the output units, “unit” to display unit symbols for both input and output units when using scientific notation, “values” for no units at all (neither unit symbols nor full words of units).

Suggested values
in off none on out unit values ~
Default
out
Example
on, unit, in, out, off
Stringsuggested
Spellingsp

Spelling of units. Use “us” to display unit names using U.S. spelling.

Example
us
Stringoptional
Adjectiveadj

Whether to use adjectival form. Use “on” for singular unit name appended by a hyphen, “mid” to put conversion at end, or “off” (default) for no adjectival form.

Suggested values
mid on pre ri0 ri1 ri2 ri3 off
Default
off
Example
on
Unbalanced wikitextoptional
Conversiondisp

Display conversion result: “or”: after ‘or’, “x”: with custom prefix and suffix, “b”: in parentheses, “table”/“tablecen”, “output only”: alone, “output number only”: alone and without unit, “unit”: not at all but input unit; if the value is a number it is used as precision.

Suggested values
b sqbr br comma or number output number only out output only preunit table tablecen unit unit2 x
Example
b
Stringoptional
Orderingorder

“flip” returns converted value first, input value second.

Suggested values
flip out
Example
flip
Stringoptional
Significant figuressigfig

Indicates the number of significant figures to be used in rounding.

Numberoptional
Rounding outputround

The type of rounding. “5” rounds the output number to nearest multiple of 5, “25” to nearest multiple of 25, “each” rounds each number in a range.

Numberoptional
Thousands separatorcomma

Sets or suppresses the use of thousands separators in the numbers. “off”: no separator; “gaps”: use space instead of comma as thousands separator; “5”: only add thousands separator when the integral part of the number uses 5 positions or more (10,000 or more; if using comma as thousands separator, 1234 would produce '1234', 12345 would produce '12,345').

Default
on
Example
off
Booleanoptional
Sort keysortable

“on” generates a hidden sort key

Example
on
Booleanoptional
Spell numbers?spell

If used, spells input or input and output numbers in words, optionally capitalizing the first

Suggested values
in In on On
Example
'in', 'In', 'on', or 'On'
Stringoptional
Singular?sing

If 'yes', uses singular form of units (deprecated)

Example
yes
Booleandeprecated
Fraction?frac

fraction as rounding unit

Numberoptional
Currency symbol$

sets currency symbol in both units

Example
$=€ will show " €10 per mile (€6.2/km)"
Stringoptional
Mach altitude (ft)altitude_ft

Mach (speed) depends on altitide

Suggested values
10000
Numberoptional
Mach altitude (m)altitude_m

Mach (speed) depends on altitude

Numberoptional
WD propertyinput

Reads the property value of the item (article), then converts it

Example
{{convert|input=P2046}} (P2046=area)
Stringoptional