Difference between revisions of "Template:Map caption/sandbox"

From blackwiki
Jump to navigation Jump to search
imported>Blue-Haired Lawyer
(proposed change)
imported>MSGJ
(tidy code)
Line 1: Line 1:
<noinclude>{{Template sandbox notice|testcases-name=sandcastle}}</noinclude><!--
+
<div style="text-align:center;font-size:11px;line-height:1.15em;"><span style="font-size:11px;">Location of {{#if:{{{countryprefix|}}}
 
+
|{{{countryprefix}}}&nbsp;
--><div style="text-align:center;font-size:11px;line-height:1.15em;"><span style="font-size:11px;">Location of <!--
+
}}<span style="font-size:2px;">&nbsp;</span>{{#ifexist:{{{country}}}
-->{{#if:<!--[0]-->{{{countryprefix|}}}
+
|[[{{{country}}}]]
      |<!--then:[0]-->{{{countryprefix}}}&nbsp;<!--
+
|{{{country|[[{{PAGENAME}}]]}}}
--end#if:[0]-->}}<span style="font-size:2px;">&nbsp;</span>{{#ifexist:{{{country}}}|[[{{{country}}}]]|{{{country|[[{{PAGENAME}}]]}}}}}<!--
+
}}{{#ifeq:{{{location|{{{location_color|any}}}}}}|none|
-->{{#ifeq:<!--[1]-->{{{location|{{{location_color|any}}}}}}|<!--equals:-->none
+
|<span style="font-size:8px;">{{spaces|2}}</span>({{{location|<span style="font-size:9px;">{{{location_color|orange}}}</span>}}})
      |<!--then:[1] either location or location_color passed as explicit demand not to indicate any (default location_color) value
+
}}</span>{{#if:{{{region|{{{legend|}}}}}}
  -->|<!--else:[1]--><span style="font-size:8px;">{{spaces|2}}</span>({{{location|<span style="font-size:9px;">{{{location_color|orange}}}</span>}}})<!--
+
|{{#if:{{{subregion|}}}
--end#ifeq:[1]-->}}</span><!--
+
  |<p style="width:250px;font-size:11px;text-align:left;margin-left:1.2ex;margin-top:0px;margin-bottom:0px;line-height:1.15em;">–&nbsp;
-->{{#if:<!--[2]-->{{{region|{{{legend|}}}}}}
+
  |<p style="width:250px;font-size:11px;text-align:center;margin-top:0px;margin-bottom:0px;line-height:1.15em;">
      |<!--then:[2]
+
}}{{#switch:{{{region|none}}}
-->{{#if:<!--[3]-->{{{subregion|}}}
+
  | none =
      |<!--then:[3]--><p style="width:250px;font-size:11px;text-align:left;margin-left:1.2ex;margin-top:0px;margin-bottom:0px;line-height:1.15em;">–&nbsp;<!--
+
  | Europe
  -->|<!--else:[3]--><p style="width:250px;font-size:11px;text-align:center;margin-top:0px;margin-bottom:0px;line-height:1.15em;"><!--
+
  | [[Europe]]
--end#if:[3]-->}}<!--
+
  | in Europe
-->{{#switch:<!--[4]-->{{{region|none}}}
+
  | in [[Europe]]
| none =
+
  | on the European continent
| Europe
+
  | on the [[Europe|European continent]] = in [[Europe]]
| [[Europe]]
+
  | Pacific
| in Europe
+
  | [[Pacific]]
| in [[Europe]]
+
  | the Pacific
| on the European continent
+
  | the [[Pacific]]
| on the [[Europe|European continent]] = in [[Europe]]
+
  | the Pacific Ocean = in the [[Pacific Ocean]]
| Pacific
+
  | Antarctica
| [[Pacific]]
+
  | [[Antarctica]] = on {{#ifexist:{{{region}}}
| the Pacific
+
  |[[{{{region}}}]]
| the [[Pacific]]
+
  |{{{region}}}
| the Pacific Ocean = in the [[Pacific Ocean]]
+
  }}
| Antarctica
+
  | Middle East
| [[Antarctica]] = on {{#ifexist:{{{region}}}|[[{{{region}}}]]|{{{region}}}}}
+
  | [[Middle East]]
| Middle East
+
  | Arctic Circle
| [[Middle East]]
+
  | [[Arctic Circle]]
| Arctic Circle
+
  | Pacific Ocean
| [[Arctic Circle]]
+
  | [[Pacific Ocean]] = in the {{#ifexist:{{{region}}}|[[{{{region}}}]]|{{{region}}}}}
| Pacific Ocean
+
  | #default = in {{#ifexist:{{{region}}}
| [[Pacific Ocean]] = in the {{#ifexist:{{{region}}}|[[{{{region}}}]]|{{{region}}}}}
+
  |[[{{{region}}}]]
| #default = in {{#ifexist:{{{region}}}|[[{{{region}}}]]|{{{region}}}}}
+
  |{{{region}}}
<!--end#switch:[4]-->}}<!--
+
  }}
-->{{#if:<!--[5]-->{{{region|}}}
+
}}{{#if:{{{region|}}}
      |<!--then:[5]
+
  |{{#ifeq:{{{region_color|any}}}|none|
-->{{#ifeq:<!--[6]-->{{{region_color|any}}}|<!--equals:-->none
+
  |<span style="font-size:8px;">{{spaces|2}}</span>(<span style="font-size:9px;">{{#if:{{{subregion|}}}
      |<!--then:[6] region_color passed as explicit demand not to indicate (default) color
+
    |{{#ifeq:{{{subregion_color|tan}}}|{{{region_color|white}}}|
  -->|<!--else:[6]--><span style="font-size:8px;">{{spaces|2}}</span>(<span style="font-size:9px;"><!--
+
    |{{#ifeq:{{{subregion_color|any}}}|none|
-->{{#if:<!--[7]-->{{{subregion|}}}
+
      |{{{subregion_color|tan}}} &&nbsp;
      |<!--then:[7]
+
    }}
-->{{#ifeq:<!--[8]-->{{{subregion_color|camel}}}|<!--equals:-->{{{region_color|white}}}
+
    }}{{{region_color|white}}}
      |<!--then:[8] mention colour once
+
    |{{{region_color|white}}}
  -->|<!--else:[8]
+
  }}</span>)
-->{{#ifeq:<!--[8a]-->{{{subregion_color|any}}}|<!--equals:-->none
+
  }}{{#if:{{{subregion|}}}
      |<!--then:[8a] mention the one colour
+
  |<br />–&nbsp;{{#switch:{{{subregion|none}}}
  -->|<!--else:[8a]-->{{{subregion_color|camel}}} &&nbsp;<!--
+
    | EU
--end#ifeq:[8a]-->}}<!--
+
    | [[EU]]
--end#ifeq:[8]-->}}{{{region_color|white}}}<!--
+
    | the EU
  -->|<!--else:[7]-->{{{region_color|white}}}<!--
+
    | the [[EU]]
--end#if:[7]-->}}</span>)<!--
+
    | European Union
--end#if:[6]-->}}<!--
+
    | [[European Union]]
-->{{#if:<!--[9]-->{{{subregion|}}}
+
    | the European Union
      |<!--then:[9]--><br />–&nbsp;<!--
+
    | the [[European Union]] = in the [[European Union]]
-->{{#switch:<!--[10]-->{{{subregion|none}}}
+
    | #default = in {{#ifexist:{{{subregion}}}
| EU
+
    |[[{{{subregion}}}]]
| [[EU]]
+
    |{{{subregion}}}
| the EU
+
    }}
| the [[EU]]
+
  }}{{#ifeq:{{{subregion_color|any}}}|none|
| European Union
+
    |<span style="font-size:8px;">{{spaces|2}}</span>(<span style="font-size:9px;">{{{subregion_color|tan}}}</span>)
| [[European Union]]
+
  }}
| the European Union
+
  }}
| the [[European Union]] = in the [[European Union]]
+
}}{{#if:{{{legend|}}}
| #default = in {{#ifexist:{{{subregion}}}|[[{{{subregion}}}]]|{{{subregion}}}}}
+
  |{{#switch:<!--[13]-->{{{subregion|none}}}
<!--end#switch[10]-->}}<!--
+
  | EU
-->{{#ifeq:<!--[11]-->{{{subregion_color|any}}}|<!--equals:-->none
+
  | [[EU]]
      |<!--then:[11] subregion_color passed as explicit demand not to indicate (default) color
+
  | the EU
  -->|<!--else:[11]--><span style="font-size:8px;">{{spaces|2}}</span>(<span style="font-size:9px;">{{{subregion_color|camel}}}</span>)<!--
+
  | the [[EU]]
--end#if:[11]-->}}<!--
+
  | European Union
--end#if:[9]-->}}<!--else:[5] no region thus no SUBregion acceptable (hence no colours indicating region or subregion at region)
+
  | [[European Union]]
--end#if:[5]-->}}<!--
+
  | the European Union
-->{{#if:<!--[12]-->{{{legend|}}}
+
  | the [[European Union]] = {{#ifeq:{{{subregion_color|tan}}}|tan
      |<!--then[12]:
+
    |{{spaces|16}}&thinsp;
-->{{#switch:<!--[13]-->{{{subregion|none}}}
+
    |&nbsp; –&nbsp;
| EU
+
  }}
| [[EU]]
+
  | none = {{#ifeq:{{{region|none}}}|none|
| the EU
+
    |&nbsp; –&nbsp;
| the [[EU]]
+
  }}
| European Union
+
  | #default = &nbsp; –&nbsp;
| [[European Union]]
+
  }} &#91;<span style="font-size:10px;">[[:File:{{{legend}}}|Legend]]</span>&#93;
| the European Union
+
}}</p>
| the [[European Union]] = <!--
+
}}</div><noinclude>
-->{{#ifeq:<!--[13a]-->{{{subregion_color|camel}}}|<!--equals:-->camel
+
{{documentation}}
      |<!--then:[13a]-->{{spaces|16}}&thinsp;<!--
+
</noinclude>
  -->|<!--else:[13a]-->&nbsp; —&nbsp;<!--
 
--end#ifeq:[13a]-->}}
 
| none = <!--
 
-->{{#ifeq:<!--[14]-->{{{region|none}}}|<!--equals:-->none
 
      |<!--then:[14] no spacer while legend has line all for itself
 
  -->|<!--else:[14]-->&nbsp; —&nbsp;<!--
 
--end#ifeq:[14]-->}}
 
| #default = &nbsp; —&nbsp;
 
<!--end#switch:[13]-->}} &#91;<span style="font-size:10px;">[[:Image:{{{legend}}}|Legend]]</span>&#93;<!--
 
--end#if:[12]-->}}</p><!--
 
--end#if:[2]-->}}</div>
 

Revision as of 13:27, 30 January 2017

Location of  Map caption/sandbox  (orange)
Template documentation[view] [edit] [history] [purge]

Template intended to simplify adding a standardized and formatted caption below a map indicating the location of something (e.g. a country), possibly referring to the map's main region and optionally also to a shown subregion. Original use within infoboxes (e.g. see articles on European countries). For a complete set of elements of reasonable length, a width of (minimally) 250px (without extra padding or margins) should be available.

Parameters

Required parameters shown in bold italics Script error: No such module "aligned table".

Note 
If country, region or subregion is exactly the name of a page in article space, the template automatically creates a link to it. You can still put a link here manually, using the usual syntax.

Examples

Code Raw result (in unformatted box, compare to handling in Infobox)
{{map caption}}
Location of Map caption/sandbox (orange)
{{map caption |region=Europe |legend=European location legend en.png}}
Location of Map caption/sandbox (orange)

in Europe (white)  –  [Legend]

{{map caption |countryprefix=the |region=Europe |subregion=the [[European Union]] |legend=European location legend en.png}}
Location of the Map caption/sandbox (orange)

– in Europe (tan & white)
– in the European Union (tan)  [Legend]

 Typical sample for an article on a European Union member that needs no "the" before its name, for otherwise identical output:
{{map caption |region=Europe |subregion=EU |legend=European location legend en.png}}
Location of Map caption/sandbox (orange)

– in Europe (tan & white)
– in the European Union (tan)  [Legend]

Infobox usage of code (as intended) — in which the alignment, the padding/margins, and font are rendered differently (this template adjusts for that infobox):
Sample for article named 'Armenia', about a non-European country

{{Infobox Country or territory|
|common_name = Armenia
|image_map = Europe location ARM.png
|map_caption = {{map caption}}
|(some required infobox parameters omitted from sample)
}}


Sample for article named 'Belarus', about a non-member of the EU
{{Infobox Country or territory|
|common_name = Belarus
|image_map = Europe location BLR.png
|map_caption = {{map caption |region=Europe |legend=European location legend en.png}}
|(some required infobox parameters omitted from sample)
}}


Sample for article named 'Netherlands', about a member of the EU
{{Infobox Country or territory|
|common_name = the Netherlands
|image_map = EU location NED.png
|map_caption = {{map caption |countryprefix=the |region=Europe |subregion=the [[European Union]] |legend=European location legend en.png}}
|(some required infobox parameters omitted from sample)
}}

Net result — The three simplified samples above, shown here side by side
Net result — (called here without country parameter, and with placeholder values for population to prevent error messages):
Location of Armenia
Location of Map caption/sandbox (orange)
Capitalx
Official languages x
Government x
Area
 -  Total 10 km² 
0 sq mi 
 -  Density 10 /km² (0)
0 /sq mi
Currency x (x)
Time zone x (UTC0)
Internet TLD x
Calling code [[+0]]
Location of Belarus
Location of Map caption/sandbox (orange)

in Europe (white)  –  [Legend]

Capitalx
Official languages x
Government x
Area
 -  Total 10 km² 
0 sq mi 
 -  Density 10 /km² (0)
0 /sq mi
Currency x (x)
Time zone x (UTC0)
Internet TLD x
Calling code [[+0]]
Location of the Netherlands
Location of the Map caption/sandbox (orange)

– in Europe (tan & white)
– in the European Union (tan)  [Legend]

Capitalx
Official languages x
Government x
Area
 -  Total 10 km² 
0 sq mi 
 -  Density 10 /km² (0)
0 /sq mi
Currency x (x)
Time zone x (UTC0)
Internet TLD x
Calling code [[+0]]