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

From blackwiki
Jump to navigation Jump to search
imported>Thayts
(added percentage option)
imported>Thayts
m
Line 2: Line 2:
 
  |<!-- sqmi and km2 -->{{formatnum:{{{km2}}}&nbsp;km<sup>2</sup> ({{{sqmi}}}&nbsp;sq&nbsp;mi)}}
 
  |<!-- sqmi and km2 -->{{formatnum:{{{km2}}}&nbsp;km<sup>2</sup> ({{{sqmi}}}&nbsp;sq&nbsp;mi)}}
 
  |{{#if:{{{km2|}}}{{{sqmi|}}}
 
  |{{#if:{{{km2|}}}{{{sqmi|}}}
   |{{convinfobox|{{{km2|}}}|km2|{{{sqmi|}}}|sqmi|disp={{#if:{{{pct|}}}|x|b}}|{{#if:{{{pct|}}}|&#32;(}}}}{{#if:{{{pct|}}}|&#59; {{{pct}}}%)}}
+
   |{{convinfobox|{{{km2|}}}|km2|{{{sqmi|}}}|sqmi|disp={{#if:{{{pct|}}}|x|b}}|{{#if:{{{pct|}}}|&#32;(}}}}{{#if:{{{pct|}}}|&#59;&#160;{{{pct}}}%)}}
 
   |{{#if:{{both|{{{ha|}}}|{{{acre|}}}}}
 
   |{{#if:{{both|{{{ha|}}}|{{{acre|}}}}}
 
     |<!-- acre and ha (and no sqmi and no km2) -->{{formatnum:{{{ha}}}&nbsp;ha ({{{acre}}}&nbsp;acres)}}
 
     |<!-- acre and ha (and no sqmi and no km2) -->{{formatnum:{{{ha}}}&nbsp;ha ({{{acre}}}&nbsp;acres)}}
 
     |{{#if:{{{ha|}}}{{{acre|}}}
 
     |{{#if:{{{ha|}}}{{{acre|}}}
       |{{convinfobox|{{{ha|}}}|ha|{{{acre|}}}|acre|disp={{#if:{{{pct|}}}|x|b}}|{{#if:{{{pct|}}}|&#32;(}}}}{{#if:{{{pct|}}}|&#59; {{{pct}}}%)}}
+
       |{{convinfobox|{{{ha|}}}|ha|{{{acre|}}}|acre|disp={{#if:{{{pct|}}}|x|b}}|{{#if:{{{pct|}}}|&#32;(}}}}{{#if:{{{pct|}}}|&#59;&#160;{{{pct}}}%)}}
 
       |{{#if:{{both|{{{sqft|}}}|{{{m2|}}}}}
 
       |{{#if:{{both|{{{sqft|}}}|{{{m2|}}}}}
 
         |<!-- sqft and m2 (and no sqmi, no km2, no ha, no acre) -->{{formatnum:{{{m2}}}&nbsp;m<sup>2</sup> ({{{sqft}}}&nbsp;sq&nbsp;ft)}}
 
         |<!-- sqft and m2 (and no sqmi, no km2, no ha, no acre) -->{{formatnum:{{{m2}}}&nbsp;m<sup>2</sup> ({{{sqft}}}&nbsp;sq&nbsp;ft)}}
 
         |{{#if:{{{sqft|}}}{{{m2|}}}
 
         |{{#if:{{{sqft|}}}{{{m2|}}}
           |{{convinfobox|{{{m2|}}}|m2|{{{sqft|}}}|sqft|disp={{#if:{{{pct|}}}|x|b}}|{{#if:{{{pct|}}}|&#32;(}}}}{{#if:{{{pct|}}}|&#59; {{{pct}}}%)}}
+
           |{{convinfobox|{{{m2|}}}|m2|{{{sqft|}}}|sqft|disp={{#if:{{{pct|}}}|x|b}}|{{#if:{{{pct|}}}|&#32;(}}}}{{#if:{{{pct|}}}|&#59;&#160;{{{pct}}}%)}}
 
           }}
 
           }}
 
         }}
 
         }}

Revision as of 13:51, 16 May 2015

Template documentation[view] [edit] [history] [purge]

This is a subtemplate of {{Infobox islands}}, and should not be used directly.

Usage

Input Output
{{Infobox islands/area|km2=0.5}} 0.5 km2 (0.19 sq mi)
{{Infobox islands/area|km2=0.5|pct=37}} 0.5 km2 (0.19 sq mi; 37%)
{{Infobox islands/area|sqmi=0.2}} 0.2 sq mi (0.52 km2)
{{Infobox islands/area|sqmi=0.2|pct=23}} 0.2 sq mi (0.52 km2; 23%)
{{Infobox islands/area|ha=5.0}} 5.0 ha (12 acres)
{{Infobox islands/area|acre=12.0}} 12.0 acres (4.9 ha)
{{Infobox islands/area|m2=500}} 500 m2 (5,400 sq ft)
{{Infobox islands/area|sqft=5410}} 5,410 sq ft (503 m2)
{{Infobox islands/area|km2=0.5|sqmi=0.2}} 0.5 km2 (0.2 sq mi)
{{Infobox islands/area|acre=12.0|ha=4.9}} 4.9 ha (12.0 acres)
{{Infobox islands/area|m2=500|sqft=5410}} 500 m2 (5,410 sq ft)
{{Infobox islands/area|km2=0.5|m2=500}} 0.5 km2 (0.19 sq mi)
{{Infobox islands/area|sqmi=0.2|sqft=5410}} 0.2 sq mi (0.52 km2)
{{Infobox islands/area|m2=500|sqmi=0.2|sqft=5410}} 0.2 sq mi (0.52 km2)
{{Infobox islands/area|km2=0.5|sqmi=0.2|sqft=5410}} 0.5 km2 (0.2 sq mi)
{{Infobox islands/area|km2=0.5|m2=500|sqft=5410}} 0.5 km2 (0.19 sq mi)
{{Infobox islands/area|km2=0.5|m2=500|sqmi=0.2}} 0.5 km2 (0.2 sq mi)
{{Infobox islands/area|km2=0.5|m2=500|sqmi=0.2|sqft=5410}} 0.5 km2 (0.2 sq mi)


  • {{convert|0.5|km2|abbr=on}} → 0.5 km2 (0.19 sq mi)
  • {{convert|0.2|sqmi|abbr=on}} → 0.2 sq mi (0.52 km2)
  • {{convert|5|ha|abbr=on}} → 5 ha (12 acres)
  • {{convert|12|acre|abbr=on}} → 12 acres (4.9 ha)
  • {{convert|500|m2|abbr=on}} → 500 m2 (5,400 sq ft)
  • {{convert|5410|sqft|abbr=on}} → 5,410 sq ft (503 m2)

Code

The code uses {{precision}} to determine the level of precision. The logic is to give preference to km2/sqmi over m2/sqft. If both km2 and sqmi are specified, then no conversion takes place. Similarly, if both m2 and sqft are specified (and km2/sqmi are not specified), then no conversion takes place.

See also