Template:Dist

From OniGalore
Jump to navigation Jump to search

Call this template to convert between metric and imperial units of length. Both the original and converted length will be displayed, with the unit you supplied coming first.

Supported conversions

Here are all the conversions supported by the template. If you want anything else to be supported, you can add it yourself; the existing code should be easy to follow.

cm-in

{{Dist|100|cm|in}}
yields
100 cm (39.37 in)

{{Dist|100|in|cm}}
yields
100 in (254 cm)

m-ft

{{Dist|100|ft|m}}
yields
100 ft (30.48 m)

{{Dist|100|m|ft}}
yields
100 m (328.08 ft)

km-mi

{{Dist|100|km|mi}}
yields
100 km (62.14 mi)

{{Dist|100|mi|km}}
yields
100 mi (160.93 km)

Precision

An optional fourth parameter specifies the number of decimal places to provide in the conversion.

{{Dist|100|mi|km|1}}
yields
100 mi (160.9 km)

{{Dist|100|mi|km|0}}
yields
100 mi (161 km)