Difference between revisions of "Template:Infobox islands/length"

From blackwiki
Jump to navigation Jump to search
imported>Plastikspork
(switch templates)
imported>Plastikspork
(Undid revision 371050631 by Plastikspork (talk))
Line 2: Line 2:
 
  |{{#if:{{{mi|}}}<!-- mi and km -->
 
  |{{#if:{{{mi|}}}<!-- mi and km -->
 
   |{{formatnum:{{{km}}}&nbsp;km ({{{mi}}}&nbsp;mi)}}
 
   |{{formatnum:{{{km}}}&nbsp;km ({{{mi}}}&nbsp;mi)}}
   |{{km to mi|{{formatnum:{{{km}}}|R}}|abbr=yes}}
+
   |{{convert|{{formatnum:{{{km}}}|R}}|km|abbr=on}}
 
  }}
 
  }}
 
  |{{#if:{{{mi|}}}<!-- mi and no km -->
 
  |{{#if:{{{mi|}}}<!-- mi and no km -->
   |{{mi to km|{{formatnum:{{{mi|}}}|R}}|abbr=yes}}
+
   |{{convert|{{formatnum:{{{mi|}}}|R}}|mi|abbr=on}}
 
   |{{#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}}}&nbsp;m ({{{ft}}}&nbsp;ft)}}
 
     |{{formatnum:{{{m}}}&nbsp;m ({{{ft}}}&nbsp;ft)}}
     |{{m to ft|{{formatnum:{{{m}}}|R}}|abbr=yes}}  
+
     |{{convert|{{formatnum:{{{m}}}|R}}|m|abbr=on}}  
 
     }}
 
     }}
 
   |{{#if:{{{ft|}}}<!-- ft and no m (and no mi and no km -->
 
   |{{#if:{{{ft|}}}<!-- ft and no m (and no mi and no km -->
     |{{ft to m|{{formatnum:{{{ft|}}}|R}}|abbr=yes}}
+
     |{{convert|{{formatnum:{{{ft|}}}|R}}|ft|abbr=on}}
 
   }}
 
   }}
 
   }}
 
   }}
 
  }}
 
  }}
 
}}<noinclude>{{documentation}}</noinclude>
 
}}<noinclude>{{documentation}}</noinclude>

Revision as of 17:52, 30 June 2010

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 (0.31 mi)
{{Infobox islands/length|mi=0.3}} 0.3 mi (0.48 km)
{{Infobox islands/length|m=500}} 500 m (1,600 ft)
{{Infobox islands/length|ft=1610}} 1,610 ft (490 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 (0.31 mi)
{{Infobox islands/length|mi=0.3|ft=1610}} 0.3 mi (0.48 km)
{{Infobox islands/length|m=500|mi=0.3|ft=1610}} 0.3 mi (0.48 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 (0.31 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