Difference between revisions of "Template:Infobox islands/length"
Jump to navigation
Jump to search
imported>Yaris678 m (Changed protection level for "Template:Infobox islands/length": For consistency with Template:Infobox islands. An increase of edit protection and decrease of move protection. ([Edit=Require template editor access] (indefinite) [Move=Require te...) |
imported>Jonesey95 (fix invalid input to formatnum causing articles to appear in Category:Pages with non-numeric formatnum arguments) |
||
| Line 1: | Line 1: | ||
{{#if:{{{km|}}} | {{#if:{{{km|}}} | ||
|{{#if:{{{mi|}}}<!-- mi and km --> | |{{#if:{{{mi|}}}<!-- mi and km --> | ||
| − | |{{formatnum:{{{km}}} km ({{{mi}}} mi) | + | |{{formatnum:{{{km}}}}} km ({{formatnum:{{{mi}}}}} mi) |
| − | |{{formatnum:{{{km}}} km ({{#expr: ({{formatnum:{{{km}}}|R}})/1.609344 round ({{precision|{{formatnum:{{{km}}}|R}}}}+1)}} mi) | + | |{{formatnum:{{{km}}}}} km ({{#expr: ({{formatnum:{{{km}}}|R}})/1.609344 round ({{precision|{{formatnum:{{{km}}}|R}}}}+1)}} mi) |
}} | }} | ||
|{{#if:{{{mi|}}}<!-- mi and no km --> | |{{#if:{{{mi|}}}<!-- mi and no km --> | ||
| − | |{{formatnum:{{{mi}}} mi ({{#expr: ({{formatnum:{{{mi}}}|R}})*1.609344 round ({{precision|{{formatnum:{{{mi}}}|R}}}}-0)}} km) | + | |{{formatnum:{{{mi}}}}} mi ({{#expr: ({{formatnum:{{{mi}}}|R}})*1.609344 round ({{precision|{{formatnum:{{{mi}}}|R}}}}-0)}} km) |
|{{#if:{{{m|}}} | |{{#if:{{{m|}}} | ||
|{{#if:{{{ft|}}}<!-- ft and m (and no mi and no km) --> | |{{#if:{{{ft|}}}<!-- ft and m (and no mi and no km) --> | ||
| − | |{{formatnum:{{{m}}} m ({{{ft}}} ft) | + | |{{formatnum:{{{m}}}}} m ({{formatnum:{{{ft}}}}} ft) |
| − | |{{formatnum:{{{m}}} m ({{#expr: ({{formatnum:{{{m}}}|R}})*3.2808399 round ({{precision|{{formatnum:{{{m}}}|R}}}}-0)}} ft) | + | |{{formatnum:{{{m}}}}} m ({{#expr: ({{formatnum:{{{m}}}|R}})*3.2808399 round ({{precision|{{formatnum:{{{m}}}|R}}}}-0)}} ft) |
}} | }} | ||
|{{#if:{{{ft|}}}<!-- ft and no m (and no mi and no km --> | |{{#if:{{{ft|}}}<!-- ft and no m (and no mi and no km --> | ||
| − | |{{formatnum:{{{ft}}} ft ({{#expr: ({{formatnum:{{{ft}}}|R}})/3.2808399 round ({{precision|{{formatnum:{{{ft}}}|R}}}}+1)}} m) | + | |{{formatnum:{{{ft}}}}} ft ({{#expr: ({{formatnum:{{{ft}}}|R}})/3.2808399 round ({{precision|{{formatnum:{{{ft}}}|R}}}}+1)}} m) |
}} | }} | ||
}} | }} | ||
}} | }} | ||
}}<noinclude>{{documentation}}</noinclude> | }}<noinclude>{{documentation}}</noinclude> | ||
Latest revision as of 00:45, 29 September 2020
This is a subtemplate of {{Infobox islands}}, and should not be used directly.
Usage
| Input | Output |
|---|---|
{{Infobox islands/length|km=0.5}} |
0.5 km (Expression error: Unrecognized punctuation character "[". mi) |
{{Infobox islands/length|mi=0.3}} |
0.3 mi (Expression error: Unrecognized punctuation character "[". km) |
{{Infobox islands/length|m=500}} |
500 m (Expression error: Unrecognized punctuation character "[". ft) |
{{Infobox islands/length|ft=1610}} |
1,610 ft (Expression error: Unrecognized punctuation character "[". m) |
{{Infobox islands/length|km=0.5|mi=0.3}} |
0.5 km (0.3 mi) |
{{Infobox islands/length|m=500|ft=1610}} |
500 m (1,610 ft) |
{{Infobox islands/length|km=0.5|m=500}} |
0.5 km (Expression error: Unrecognized punctuation character "[". mi) |
{{Infobox islands/length|mi=0.3|ft=1610}} |
0.3 mi (Expression error: Unrecognized punctuation character "[". km) |
{{Infobox islands/length|m=500|mi=0.3|ft=1610}} |
0.3 mi (Expression error: Unrecognized punctuation character "[". km) |
{{Infobox islands/length|km=0.5|mi=0.3|ft=1610}} |
0.5 km (0.3 mi) |
{{Infobox islands/length|km=0.5|m=500|ft=1610}} |
0.5 km (Expression error: Unrecognized punctuation character "[". mi) |
{{Infobox islands/length|km=0.5|m=500|mi=0.3}} |
0.5 km (0.3 mi) |
{{Infobox islands/length|km=0.5|m=500|mi=0.3|ft=1610}} |
0.5 km (0.3 mi) |
{{convert|0.5|km|abbr=on}}→ 0.5 km (0.31 mi){{convert|0.3|mi|abbr=on}}→ 0.3 mi (0.48 km){{convert|500|m|abbr=on}}→ 500 m (1,600 ft){{convert|1610|ft|abbr=on}}→ 1,610 ft (490 m)
Code
The code uses {{precision}} to determine the level of precision. The logic is to give preference to km/mi over m/ft. If both km and mi are specified, then no conversion takes place. Similarly, if both m and ft are specified (and km/mi are not specified), then no conversion takes place.
See also
- {{convert}}
- {{Infobox islands/area}}
- {{Infobox islands/density}}
| The above documentation is transcluded from Template:Infobox islands/length/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this template. |