Template:Convert: Difference between revisions
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 = | |||
{{#switch: {{{toUnit}}} | {{#switch: {{{toUnit}}} | ||
| foot = fromUnit is the same as toUnit, check your units. | |||
| inch ={{{value}}}ft({{#expr: {{{value}}} * 12}}in) | |||
| mm ={{{value}}}ft({{#expr: {{{value}}} * 304.8}}mm) | |||
| cm ={{{value}}}ft({{#expr: {{{value}}} * 30.48}}cm) | |||
| m ={{{value}}}ft({{#expr: {{{value}}} / 3.281}}m) | |||
| #default = Missing/Invalid/Unsupported toUnit: {{{toUnit}}} | |||
}} | }} | ||
| inch = | |||
{{#switch: {{{toUnit}}} | {{#switch: {{{toUnit}}} | ||
| foot ={{{value}}}in({{#expr: {{{value}}} / 12}}ft) | |||
| inch = fromUnit is the same as toUnit, check your units. | |||
| mm ={{{value}}}in({{#expr: {{{value}}} * 25.4}}mm) | |||
| cm ={{{value}}}in({{#expr: {{{value}}} * 2.54}}cm) | |||
| m ={{{value}}}in({{#expr: {{{value}}} / 39.37}}m) | |||
| #default =Missing/Invalid/Unsupported toUnit: {{{toUnit}}} | |||
}} | }} | ||
| mm = | |||
{{#switch: {{{toUnit}}} | {{#switch: {{{toUnit}}} | ||
| foot ={{{value}}}mm({{#expr: {{{value}}} / 304.8}}ft) | |||
| inch ={{{value}}}mm({{#expr: {{{value}}} / 25.4}}in) | |||
| mm = fromUnit is the same as toUnit, check your units. | |||
| cm ={{{value}}}mm({{#expr: {{{value}}} / 10 }}cm) | |||
| m ={{{value}}}mm({{#expr: {{{value}}} / 1000}}m) | |||
| #default = Missing/Invalid/Unsupported toUnit: {{{toUnit}}} | |||
}} | }} | ||
| cm = | |||
{{#switch: {{{toUnit}}} | {{#switch: {{{toUnit}}} | ||
| foot ={{{value}}}cm({{#expr: {{{value}}} / 30.48}}ft) | |||
| inch ={{{value}}}cm({{#expr: {{{value}}} / 2.54}}in) | |||
| mm ={{{value}}}cm({{#expr: {{{value}}} * 10}}mm) | |||
| cm = fromUnit is the same as toUnit, check your units. | |||
| m ={{{value}}}cm({{#expr: {{{value}}} / 100}}m) | |||
| #default = Missing/Invalid/Unsupported toUnit: {{{toUnit}}} | |||
}} | }} | ||
| m = | |||
{{#switch: {{{toUnit}}} | {{#switch: {{{toUnit}}} | ||
| foot = {{{value}}}m({{#expr: {{{value}}} *3.281}}ft) | |||
| inch ={{{value}}}m({{#expr: {{{value}}} * 39.37}}in) | |||
| mm ={{{value}}}m({{#expr: {{{value}}} * 100}}mm) | |||
| cm ={{{value}}}m({{#expr: {{{value}}} * 10}}cm) | |||
| m = fromUnit is the same as toUnit, check your units. | |||
| #default = Missing/Invalid/Unsupported toUnit: {{{toUnit}}} | |||
}} | }} | ||
| c = | |||
{{#switch: {{{toUnit}}} | {{#switch: {{{toUnit}}} | ||
| f ={{{value}}}°C({{#expr: ({{{value}}} × 9/5) + 32}}°F) | |||
| #default =Missing/Invalid/Unsupported toUnit: {{{toUnit}}} | |||
}} | }} | ||
| f = | |||
{{#switch: {{{toUnit}}} | {{#switch: {{{toUnit}}} | ||
| c ={{{value}}}°F({{#expr: ({{{value}}} − 32) × 5/9 }}°C) | |||
| #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.
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| fromUnit | fromUnit | Origin unit this measurement was made in.
| String | required |
| toUnit | toUnit | The unit that the measured value should be converted to.
| String | required |
| value | value | The measured value to convert from.
| Number | required |