Changes
Template:Infobox person/height/locate/doc (view source)
Revision as of 09:56, 12 July 2018
, 6 years agoreplace template name in first sentence, it is shown in numbered list below
{{Documentation subpage}}
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
This is one of three templates used to automatically add conversions of height measurements displayed by [[Template:Infobox person]] and other [[:Category:Infobox templates|infoboxes]] with a {{para|height}} parameter.
# [[Template:Infobox person/height]] changes text for units of height to the abbreviations "m", "cm", "ft", or "in", then passes the string to:
# [[Template:Infobox person/height/locate]] which replaces any instances of <code>&nbsp;</code> with a space, and determines the positions of "m", "cm", "ft", or "in" within that string, all of which is passed to:
# [[Template:Infobox person/height/switch]] which does the conversion
== Usage ==
* <code><nowiki>{{Template:Infobox person/height/locate|1.57 m}}</nowiki></code> → {{Template:Infobox person/height/locate|1.57 m}}
* <code><nowiki>{{Template:Infobox person/height/locate|1.57&nbsp;m}}</nowiki></code> → {{Template:Infobox person/height/locate|1.57 m}}
* <code><nowiki>{{Template:Infobox person/height/locate|157 cm}}</nowiki></code> → {{Template:Infobox person/height/locate|157 cm}}
* <code><nowiki>{{Template:Infobox person/height/locate|157&nbsp;cm}}</nowiki></code> → {{Template:Infobox person/height/locate|157 cm}}
* <code><nowiki>{{Template:Infobox person/height/locate|5 ft}}</nowiki></code> → {{Template:Infobox person/height/locate|5 ft}}
* <code><nowiki>{{Template:Infobox person/height/locate|5&nbsp;ft}}</nowiki></code> → {{Template:Infobox person/height/locate|5 ft}}
* <code><nowiki>{{Template:Infobox person/height/locate|2 in}}</nowiki></code> → {{Template:Infobox person/height/locate|2 in}}
* <code><nowiki>{{Template:Infobox person/height/locate|2&nbsp;in}}</nowiki></code> → {{Template:Infobox person/height/locate|2 in}}
* <code><nowiki>{{Template:Infobox person/height/locate|5 ft 2 in}}</nowiki></code> → {{Template:Infobox person/height/locate|5 ft 2 in}}
* <code><nowiki>{{Template:Infobox person/height/locate|5&nbsp;ft 2&nbsp;in}}</nowiki></code> → {{Template:Infobox person/height/locate|5 ft 2 in}}
* <code><nowiki>{{Template:Infobox person/height/locate|5&nbsp;ft 2&nbsp;in (2012)}}</nowiki></code> → {{Template:Infobox person/height/locate|5 ft 2 in (2012)}}
* <code><nowiki>{{Template:Infobox person/height/locate|5&nbsp;ft 2&nbsp;in (2012)<ref>citation goes here</ref>}}</nowiki></code> → {{Template:Infobox person/height/locate|5 ft 2 in (2012)<ref>citation goes here</ref>}}
<references />
== Exceptions ==
Does not replace numbers in hard-coded conversions (examples intentionally show incorrect conversions):
* <code><nowiki>{{Template:Infobox person/height/locate|5 ft 2 in (100 cm)}}</nowiki></code> → {{Template:Infobox person/height/locate|5 ft 2 in (100 cm)}}
* <code><nowiki>{{Template:Infobox person/height/locate|157 cm (5 ft 5 in)}}</nowiki></code> → {{Template:Infobox person/height/locate|157 cm (5 ft 5 in)}}
Does not replace numeric output of conversion templates such as {{tl|convert}} or {{tl|height}} (examples have precision different than usual):
* <code><nowiki>{{Template:Infobox person/height/locate|{{convert|5|ft|2|in|m|3|abbr=on}}}}</nowiki></code> → {{Template:Infobox person/height/locate|{{convert|5|ft|2|in|m|3|abbr=on}}}}
* <code><nowiki>{{Template:Infobox person/height/locate|{{convert|1.57|m|ftin|1|abbr=on}}}}</nowiki></code> → {{Template:Infobox person/height/locate|{{convert|1.57|m|ftin|1|abbr=on}}}}
* <code><nowiki>{{Template:Infobox person/height/locate|{{height|ft=5|in=2|precision=3|abbr=yes}}}}</nowiki></code> → {{Template:Infobox person/height/locate|{{height|ft=5|in=2|precision=3|abbr=yes}}}}
* <code><nowiki>{{Template:Infobox person/height/locate|{{height|m=1.57|frac=16|abbr=yes}}}}</nowiki></code> → {{Template:Infobox person/height/locate|{{height|m=1.57|frac=16|abbr=yes}}}}
== Technical details ==
The following examples show how the template works:
=== ft & in ===
<pre>
{{Infobox person/height/switch
|{{{1|5 ft 2&nbsp;in}}}
|{{#invoke:String|replace|{{{1|5 ft 2&nbsp;in}}}|&nbsp;| }}
|m={{#invoke:String|find|{{#invoke:String|replace|{{{1|5 ft 2&nbsp;in}}}|&nbsp;| }}|m}}
|c={{#invoke:String|find|{{#invoke:String|replace|{{{1|5 ft 2&nbsp;in}}}|&nbsp;| }}|cm}}
|f={{#invoke:String|find|{{#invoke:String|replace|{{{1|5 ft 2&nbsp;in}}}|&nbsp;| }}|ft}}
|i={{#invoke:String|find|{{#invoke:String|replace|{{{1|5 ft 2&nbsp;in}}}|&nbsp;| }}|in}}
}}
</pre>
Result:<br /><code>
<nowiki>{{Infobox person/height/switch</nowiki>
<nowiki> |</nowiki>{{{1|5 ft 2&nbsp;in}}}
<nowiki> |</nowiki>{{#invoke:String|replace|{{{1|5 ft 2 in}}}| | }}
<nowiki> |m=</nowiki>{{#invoke:String|find|{{#invoke:String|replace|{{{1|5 ft 2 in}}}| | }}|m}}
<nowiki> |c=</nowiki>{{#invoke:String|find|{{#invoke:String|replace|{{{1|5 ft 2 in}}}| | }}|cm}}
<nowiki> |f=</nowiki>{{#invoke:String|find|{{#invoke:String|replace|{{{1|5 ft 2 in}}}| | }}|ft}}
<nowiki> |i=</nowiki>{{#invoke:String|find|{{#invoke:String|replace|{{{1|5 ft 2 in}}}| | }}|in}}
<nowiki>}}</nowiki>
</code>
=== cm ===
<pre>
{{Infobox person/height/switch
|{{{1|198&nbsp;cm}}}
|{{#invoke:String|replace|{{{1|198&nbsp;cm}}}|&nbsp;| }}
|m={{#invoke:String|find|{{#invoke:String|replace|{{{1|198&nbsp;cm}}}|&nbsp;| }}|m}}
|c={{#invoke:String|find|{{#invoke:String|replace|{{{1|198&nbsp;cm}}}|&nbsp;| }}|cm}}
|f={{#invoke:String|find|{{#invoke:String|replace|{{{1|198&nbsp;cm}}}|&nbsp;| }}|ft}}
|i={{#invoke:String|find|{{#invoke:String|replace|{{{1|198&nbsp;cm}}}|&nbsp;| }}|in}}
}}
</pre>
Result:<br /><code>
<nowiki>{{Infobox person/height/switch</nowiki>
<nowiki> |</nowiki>{{{1|198&nbsp;cm}}}
<nowiki> |</nowiki>{{#invoke:String|replace|{{{1|198 cm}}}| | }}
<nowiki> |m=</nowiki>{{#invoke:String|find|{{#invoke:String|replace|{{{1|198 cm}}}| | }}|m}}
<nowiki> |c=</nowiki>{{#invoke:String|find|{{#invoke:String|replace|{{{1|198 cm}}}| | }}|cm}}
<nowiki> |f=</nowiki>{{#invoke:String|find|{{#invoke:String|replace|{{{1|198 cm}}}| | }}|ft}}
<nowiki> |i=</nowiki>{{#invoke:String|find|{{#invoke:String|replace|{{{1|198 cm}}}| | }}|in}}
<nowiki>}}</nowiki>
</code>
=== m ===
<pre>
{{Infobox person/height/switch
|{{{1|1.98&nbsp;m}}}
|{{#invoke:String|replace|{{{1|1.98&nbsp;m}}}|&nbsp;| }}
|m={{#invoke:String|find|{{#invoke:String|replace|{{{1|1.98&nbsp;m}}}|&nbsp;| }}|m}}
|c={{#invoke:String|find|{{#invoke:String|replace|{{{1|1.98&nbsp;m}}}|&nbsp;| }}|cm}}
|f={{#invoke:String|find|{{#invoke:String|replace|{{{1|1.98&nbsp;m}}}|&nbsp;| }}|ft}}
|i={{#invoke:String|find|{{#invoke:String|replace|{{{1|1.98&nbsp;m}}}|&nbsp;| }}|in}}
}}
</pre>
Result:<br /><code>
<nowiki>{{Infobox person/height/switch</nowiki>
<nowiki> |</nowiki>{{{1|1.98&nbsp;m}}}
<nowiki> |</nowiki>{{#invoke:String|replace|{{{1|1.98 m}}}| | }}
<nowiki> |m=</nowiki>{{#invoke:String|find|{{#invoke:String|replace|{{{1|1.98 m}}}| | }}|m}}
<nowiki> |c=</nowiki>{{#invoke:String|find|{{#invoke:String|replace|{{{1|1.98 m}}}| | }}|cm}}
<nowiki> |f=</nowiki>{{#invoke:String|find|{{#invoke:String|replace|{{{1|1.98 m}}}| | }}|ft}}
<nowiki> |i=</nowiki>{{#invoke:String|find|{{#invoke:String|replace|{{{1|1.98 m}}}| | }}|in}}
<nowiki>}}</nowiki>
</code>
== See also ==
* [[Template:Infobox person]]
* [[Template:Infobox person/weight]]
** [[Template:Infobox person/weight/locate]]
** [[Template:Infobox person/weight/switch]]
* [[Template:Infobox person/length]]
** [[Template:Infobox person/length/locate]]
** [[Template:Infobox person/length/switch]]
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | |
<!-- Categories below this line, please; interwikis at Wikidata -->
[[Category:Template implementation details]]
}}</includeonly>
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
This is one of three templates used to automatically add conversions of height measurements displayed by [[Template:Infobox person]] and other [[:Category:Infobox templates|infoboxes]] with a {{para|height}} parameter.
# [[Template:Infobox person/height]] changes text for units of height to the abbreviations "m", "cm", "ft", or "in", then passes the string to:
# [[Template:Infobox person/height/locate]] which replaces any instances of <code>&nbsp;</code> with a space, and determines the positions of "m", "cm", "ft", or "in" within that string, all of which is passed to:
# [[Template:Infobox person/height/switch]] which does the conversion
== Usage ==
* <code><nowiki>{{Template:Infobox person/height/locate|1.57 m}}</nowiki></code> → {{Template:Infobox person/height/locate|1.57 m}}
* <code><nowiki>{{Template:Infobox person/height/locate|1.57&nbsp;m}}</nowiki></code> → {{Template:Infobox person/height/locate|1.57 m}}
* <code><nowiki>{{Template:Infobox person/height/locate|157 cm}}</nowiki></code> → {{Template:Infobox person/height/locate|157 cm}}
* <code><nowiki>{{Template:Infobox person/height/locate|157&nbsp;cm}}</nowiki></code> → {{Template:Infobox person/height/locate|157 cm}}
* <code><nowiki>{{Template:Infobox person/height/locate|5 ft}}</nowiki></code> → {{Template:Infobox person/height/locate|5 ft}}
* <code><nowiki>{{Template:Infobox person/height/locate|5&nbsp;ft}}</nowiki></code> → {{Template:Infobox person/height/locate|5 ft}}
* <code><nowiki>{{Template:Infobox person/height/locate|2 in}}</nowiki></code> → {{Template:Infobox person/height/locate|2 in}}
* <code><nowiki>{{Template:Infobox person/height/locate|2&nbsp;in}}</nowiki></code> → {{Template:Infobox person/height/locate|2 in}}
* <code><nowiki>{{Template:Infobox person/height/locate|5 ft 2 in}}</nowiki></code> → {{Template:Infobox person/height/locate|5 ft 2 in}}
* <code><nowiki>{{Template:Infobox person/height/locate|5&nbsp;ft 2&nbsp;in}}</nowiki></code> → {{Template:Infobox person/height/locate|5 ft 2 in}}
* <code><nowiki>{{Template:Infobox person/height/locate|5&nbsp;ft 2&nbsp;in (2012)}}</nowiki></code> → {{Template:Infobox person/height/locate|5 ft 2 in (2012)}}
* <code><nowiki>{{Template:Infobox person/height/locate|5&nbsp;ft 2&nbsp;in (2012)<ref>citation goes here</ref>}}</nowiki></code> → {{Template:Infobox person/height/locate|5 ft 2 in (2012)<ref>citation goes here</ref>}}
<references />
== Exceptions ==
Does not replace numbers in hard-coded conversions (examples intentionally show incorrect conversions):
* <code><nowiki>{{Template:Infobox person/height/locate|5 ft 2 in (100 cm)}}</nowiki></code> → {{Template:Infobox person/height/locate|5 ft 2 in (100 cm)}}
* <code><nowiki>{{Template:Infobox person/height/locate|157 cm (5 ft 5 in)}}</nowiki></code> → {{Template:Infobox person/height/locate|157 cm (5 ft 5 in)}}
Does not replace numeric output of conversion templates such as {{tl|convert}} or {{tl|height}} (examples have precision different than usual):
* <code><nowiki>{{Template:Infobox person/height/locate|{{convert|5|ft|2|in|m|3|abbr=on}}}}</nowiki></code> → {{Template:Infobox person/height/locate|{{convert|5|ft|2|in|m|3|abbr=on}}}}
* <code><nowiki>{{Template:Infobox person/height/locate|{{convert|1.57|m|ftin|1|abbr=on}}}}</nowiki></code> → {{Template:Infobox person/height/locate|{{convert|1.57|m|ftin|1|abbr=on}}}}
* <code><nowiki>{{Template:Infobox person/height/locate|{{height|ft=5|in=2|precision=3|abbr=yes}}}}</nowiki></code> → {{Template:Infobox person/height/locate|{{height|ft=5|in=2|precision=3|abbr=yes}}}}
* <code><nowiki>{{Template:Infobox person/height/locate|{{height|m=1.57|frac=16|abbr=yes}}}}</nowiki></code> → {{Template:Infobox person/height/locate|{{height|m=1.57|frac=16|abbr=yes}}}}
== Technical details ==
The following examples show how the template works:
=== ft & in ===
<pre>
{{Infobox person/height/switch
|{{{1|5 ft 2&nbsp;in}}}
|{{#invoke:String|replace|{{{1|5 ft 2&nbsp;in}}}|&nbsp;| }}
|m={{#invoke:String|find|{{#invoke:String|replace|{{{1|5 ft 2&nbsp;in}}}|&nbsp;| }}|m}}
|c={{#invoke:String|find|{{#invoke:String|replace|{{{1|5 ft 2&nbsp;in}}}|&nbsp;| }}|cm}}
|f={{#invoke:String|find|{{#invoke:String|replace|{{{1|5 ft 2&nbsp;in}}}|&nbsp;| }}|ft}}
|i={{#invoke:String|find|{{#invoke:String|replace|{{{1|5 ft 2&nbsp;in}}}|&nbsp;| }}|in}}
}}
</pre>
Result:<br /><code>
<nowiki>{{Infobox person/height/switch</nowiki>
<nowiki> |</nowiki>{{{1|5 ft 2&nbsp;in}}}
<nowiki> |</nowiki>{{#invoke:String|replace|{{{1|5 ft 2 in}}}| | }}
<nowiki> |m=</nowiki>{{#invoke:String|find|{{#invoke:String|replace|{{{1|5 ft 2 in}}}| | }}|m}}
<nowiki> |c=</nowiki>{{#invoke:String|find|{{#invoke:String|replace|{{{1|5 ft 2 in}}}| | }}|cm}}
<nowiki> |f=</nowiki>{{#invoke:String|find|{{#invoke:String|replace|{{{1|5 ft 2 in}}}| | }}|ft}}
<nowiki> |i=</nowiki>{{#invoke:String|find|{{#invoke:String|replace|{{{1|5 ft 2 in}}}| | }}|in}}
<nowiki>}}</nowiki>
</code>
=== cm ===
<pre>
{{Infobox person/height/switch
|{{{1|198&nbsp;cm}}}
|{{#invoke:String|replace|{{{1|198&nbsp;cm}}}|&nbsp;| }}
|m={{#invoke:String|find|{{#invoke:String|replace|{{{1|198&nbsp;cm}}}|&nbsp;| }}|m}}
|c={{#invoke:String|find|{{#invoke:String|replace|{{{1|198&nbsp;cm}}}|&nbsp;| }}|cm}}
|f={{#invoke:String|find|{{#invoke:String|replace|{{{1|198&nbsp;cm}}}|&nbsp;| }}|ft}}
|i={{#invoke:String|find|{{#invoke:String|replace|{{{1|198&nbsp;cm}}}|&nbsp;| }}|in}}
}}
</pre>
Result:<br /><code>
<nowiki>{{Infobox person/height/switch</nowiki>
<nowiki> |</nowiki>{{{1|198&nbsp;cm}}}
<nowiki> |</nowiki>{{#invoke:String|replace|{{{1|198 cm}}}| | }}
<nowiki> |m=</nowiki>{{#invoke:String|find|{{#invoke:String|replace|{{{1|198 cm}}}| | }}|m}}
<nowiki> |c=</nowiki>{{#invoke:String|find|{{#invoke:String|replace|{{{1|198 cm}}}| | }}|cm}}
<nowiki> |f=</nowiki>{{#invoke:String|find|{{#invoke:String|replace|{{{1|198 cm}}}| | }}|ft}}
<nowiki> |i=</nowiki>{{#invoke:String|find|{{#invoke:String|replace|{{{1|198 cm}}}| | }}|in}}
<nowiki>}}</nowiki>
</code>
=== m ===
<pre>
{{Infobox person/height/switch
|{{{1|1.98&nbsp;m}}}
|{{#invoke:String|replace|{{{1|1.98&nbsp;m}}}|&nbsp;| }}
|m={{#invoke:String|find|{{#invoke:String|replace|{{{1|1.98&nbsp;m}}}|&nbsp;| }}|m}}
|c={{#invoke:String|find|{{#invoke:String|replace|{{{1|1.98&nbsp;m}}}|&nbsp;| }}|cm}}
|f={{#invoke:String|find|{{#invoke:String|replace|{{{1|1.98&nbsp;m}}}|&nbsp;| }}|ft}}
|i={{#invoke:String|find|{{#invoke:String|replace|{{{1|1.98&nbsp;m}}}|&nbsp;| }}|in}}
}}
</pre>
Result:<br /><code>
<nowiki>{{Infobox person/height/switch</nowiki>
<nowiki> |</nowiki>{{{1|1.98&nbsp;m}}}
<nowiki> |</nowiki>{{#invoke:String|replace|{{{1|1.98 m}}}| | }}
<nowiki> |m=</nowiki>{{#invoke:String|find|{{#invoke:String|replace|{{{1|1.98 m}}}| | }}|m}}
<nowiki> |c=</nowiki>{{#invoke:String|find|{{#invoke:String|replace|{{{1|1.98 m}}}| | }}|cm}}
<nowiki> |f=</nowiki>{{#invoke:String|find|{{#invoke:String|replace|{{{1|1.98 m}}}| | }}|ft}}
<nowiki> |i=</nowiki>{{#invoke:String|find|{{#invoke:String|replace|{{{1|1.98 m}}}| | }}|in}}
<nowiki>}}</nowiki>
</code>
== See also ==
* [[Template:Infobox person]]
* [[Template:Infobox person/weight]]
** [[Template:Infobox person/weight/locate]]
** [[Template:Infobox person/weight/switch]]
* [[Template:Infobox person/length]]
** [[Template:Infobox person/length/locate]]
** [[Template:Infobox person/length/switch]]
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | |
<!-- Categories below this line, please; interwikis at Wikidata -->
[[Category:Template implementation details]]
}}</includeonly>