Template:Convert: Difference between revisions

From Working With Glass
Jump to navigation Jump to search
Yay conversion template.
 
Attempt to remove stray space this template adds at the end when used.
Line 1: Line 1:
{{#switch: {{{fromUnit}}}
{{#switch: {{{fromUnit}}}
| foot =  
| foot =
{{#switch: {{{toUnit}}}
{{#switch: {{{toUnit}}}
| foot = fromUnit is the same as toUnit, check your units.
| foot = fromUnit is the same as toUnit, check your units.
| inch = {{{value}}}ft({{#expr: {{{value}}} * 12 }}in)
| inch ={{{value}}}ft({{#expr: {{{value}}} * 12}}in)
| mm = {{{value}}}ft({{#expr: {{{value}}} * 304.8 }}mm)
| mm ={{{value}}}ft({{#expr: {{{value}}} * 304.8}}mm)
| cm = {{{value}}}ft({{#expr: {{{value}}} * 30.48 }}cm)
| cm ={{{value}}}ft({{#expr: {{{value}}} * 30.48}}cm)
| m = {{{value}}}ft({{#expr: {{{value}}} / 3.281 }}m)
| m ={{{value}}}ft({{#expr: {{{value}}} / 3.281}}m)
| #default = Missing/Invalid/Unsupported toUnit: {{{toUnit}}}
| #default = Missing/Invalid/Unsupported toUnit: {{{toUnit}}}
}}
}}
| inch =  
| inch =  
{{#switch: {{{toUnit}}}
{{#switch: {{{toUnit}}}
| foot = {{{value}}}in({{#expr: {{{value}}} / 12 }}ft)
| foot ={{{value}}}in({{#expr: {{{value}}} / 12}}ft)
| inch = fromUnit is the same as toUnit, check your units.
| inch = fromUnit is the same as toUnit, check your units.
| mm = {{{value}}}in({{#expr: {{{value}}} * 25.4 }}mm)
| mm ={{{value}}}in({{#expr: {{{value}}} * 25.4}}mm)
| cm = {{{value}}}in({{#expr: {{{value}}} * 2.54 }}cm)
| cm ={{{value}}}in({{#expr: {{{value}}} * 2.54}}cm)
| m = {{{value}}}in({{#expr: {{{value}}} / 39.37 }}m)
| m ={{{value}}}in({{#expr: {{{value}}} / 39.37}}m)
| #default = Missing/Invalid/Unsupported toUnit: {{{toUnit}}}
| #default =Missing/Invalid/Unsupported toUnit: {{{toUnit}}}
}}
}}
| mm =  
| mm =  
{{#switch: {{{toUnit}}}
{{#switch: {{{toUnit}}}
| foot = {{{value}}}mm({{#expr: {{{value}}} / 304.8 }}ft)
| foot ={{{value}}}mm({{#expr: {{{value}}} / 304.8}}ft)
| inch = {{{value}}}mm({{#expr: {{{value}}} / 25.4 }}in)
| inch ={{{value}}}mm({{#expr: {{{value}}} / 25.4}}in)
| mm = fromUnit is the same as toUnit, check your units.
| mm = fromUnit is the same as toUnit, check your units.
| cm = {{{value}}}mm({{#expr: {{{value}}} / 10 }}cm)
| cm ={{{value}}}mm({{#expr: {{{value}}} / 10 }}cm)
| m = {{{value}}}mm({{#expr: {{{value}}} / 1000 }}m)
| m ={{{value}}}mm({{#expr: {{{value}}} / 1000}}m)
| #default = Missing/Invalid/Unsupported toUnit: {{{toUnit}}}
| #default = Missing/Invalid/Unsupported toUnit: {{{toUnit}}}
}}
}}
| cm =  
| cm =  
{{#switch: {{{toUnit}}}
{{#switch: {{{toUnit}}}
| foot = {{{value}}}cm({{#expr: {{{value}}} / 30.48 }}ft)
| foot ={{{value}}}cm({{#expr: {{{value}}} / 30.48}}ft)
| inch = {{{value}}}cm({{#expr: {{{value}}} / 2.54 }}in)
| inch ={{{value}}}cm({{#expr: {{{value}}} / 2.54}}in)
| mm = {{{value}}}cm({{#expr: {{{value}}} * 10 }}mm)
| mm ={{{value}}}cm({{#expr: {{{value}}} * 10}}mm)
| cm = fromUnit is the same as toUnit, check your units.
| cm = fromUnit is the same as toUnit, check your units.
| m = {{{value}}}cm({{#expr: {{{value}}} / 100 }}m)
| m ={{{value}}}cm({{#expr: {{{value}}} / 100}}m)
| #default = Missing/Invalid/Unsupported toUnit: {{{toUnit}}}
| #default = Missing/Invalid/Unsupported toUnit: {{{toUnit}}}
}}
}}
| m =  
| m =  
{{#switch: {{{toUnit}}}
{{#switch: {{{toUnit}}}
| foot = {{{value}}}m({{#expr: {{{value}}} *3.281 }}ft)
| foot = {{{value}}}m({{#expr: {{{value}}} *3.281}}ft)
| inch = {{{value}}}m({{#expr: {{{value}}} * 39.37 }}in)
| inch ={{{value}}}m({{#expr: {{{value}}} * 39.37}}in)
| mm = {{{value}}}m({{#expr: {{{value}}} * 100 }}mm)
| mm ={{{value}}}m({{#expr: {{{value}}} * 100}}mm)
| cm = {{{value}}}m({{#expr: {{{value}}} * 10 }}cm)
| cm ={{{value}}}m({{#expr: {{{value}}} * 10}}cm)
| m = fromUnit is the same as toUnit, check your units.
| m = fromUnit is the same as toUnit, check your units.
| #default = Missing/Invalid/Unsupported toUnit: {{{toUnit}}}
| #default = Missing/Invalid/Unsupported toUnit: {{{toUnit}}}
}}
}}
| c =  
| c =  
{{#switch: {{{toUnit}}}
{{#switch: {{{toUnit}}}
| f = {{{value}}}°C({{#expr: ({{{value}}} × 9/5) + 32 }}°F)
| f ={{{value}}}°C({{#expr: ({{{value}}} × 9/5) + 32}}°F)
| #default = Missing/Invalid/Unsupported toUnit: {{{toUnit}}}
| #default =Missing/Invalid/Unsupported toUnit: {{{toUnit}}}
}}
}}
| f =  
| f =
{{#switch: {{{toUnit}}}
{{#switch: {{{toUnit}}}
| c = {{{value}}}°F({{#expr: ({{{value}}} − 32) × 5/9 }}°C)
| c ={{{value}}}°F({{#expr: ({{{value}}} − 32) × 5/9 }}°C)
| #default = Missing/Invalid/Unsupported toUnit: {{{toUnit}}}
| #default =Missing/Invalid/Unsupported toUnit: {{{toUnit}}}
}}
}}}}
 
}}
<noinclude>
<noinclude>
<templatedata>
<templatedata>

Revision as of 07:28, 23 October 2025


Basic measurement conversion template for displaying both metric and imperial units at the same time regardless of input type.

Template parameters[Edit template data]

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
fromUnitfromUnit

Origin unit this measurement was made in.

Suggested values
foot inch mm cm m f c
Example
inch
Stringrequired
toUnittoUnit

The unit that the measured value should be converted to.

Suggested values
foot inch mm cm m c f
Example
cm
Stringrequired
valuevalue

The measured value to convert from.

Example
12
Numberrequired