Difference between revisions of "Template:Infobox person/height/locate/doc"
en>Zyxw m (replace template name in first sentence, it is shown in numbered list below) |
m (1 revision imported) |
(No difference)
|
Latest revision as of 01:39, 29 December 2018
This is a documentation subpage for Template:Infobox person/height/locate. It contains usage information, categories and other content that is not part of the original template page. |
This is one of three templates used to automatically add conversions of height measurements displayed by Template:Infobox person and other infoboxes with a |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
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
{{Template:Infobox person/height/locate|1.57 m}}
→ 1.57 m (5 ft 2 in){{Template:Infobox person/height/locate|1.57 m}}
→ 1.57 m (5 ft 2 in){{Template:Infobox person/height/locate|157 cm}}
→ 157 cm (5 ft 2 in){{Template:Infobox person/height/locate|157 cm}}
→ 157 cm (5 ft 2 in){{Template:Infobox person/height/locate|5 ft}}
→ 5 ft (152 cm){{Template:Infobox person/height/locate|5 ft}}
→ 5 ft (152 cm){{Template:Infobox person/height/locate|2 in}}
→ 2 in (5 cm){{Template:Infobox person/height/locate|2 in}}
→ 2 in (5 cm){{Template:Infobox person/height/locate|5 ft 2 in}}
→ 5 ft 2 in (157 cm){{Template:Infobox person/height/locate|5 ft 2 in}}
→ 5 ft 2 in (157 cm){{Template:Infobox person/height/locate|5 ft 2 in (2012)}}
→ 5 ft 2 in (157 cm) (2012){{Template:Infobox person/height/locate|5 ft 2 in (2012)<ref>citation goes here</ref>}}
→ 5 ft 2 in (157 cm) (2012)[1]
- ↑ citation goes here
Exceptions
Does not replace numbers in hard-coded conversions (examples intentionally show incorrect conversions):
{{Template:Infobox person/height/locate|5 ft 2 in (100 cm)}}
→ 5 ft 2 in (100 cm){{Template:Infobox person/height/locate|157 cm (5 ft 5 in)}}
→ 157 cm (5 ft 5 in)
Does not replace numeric output of conversion templates such as {{convert}} or {{height}} (examples have precision different than usual):
{{Template:Infobox person/height/locate|{{convert|5|ft|2|in|m|3|abbr=on}}}}
→ 5 ft 2 in (1.575 m){{Template:Infobox person/height/locate|{{convert|1.57|m|ftin|1|abbr=on}}}}
→ 1.57 m (5 ft 1.8 in){{Template:Infobox person/height/locate|{{height|ft=5|in=2|precision=3|abbr=yes}}}}
→ 5 ft 2 in (1.575 m){{Template:Infobox person/height/locate|{{height|m=1.57|frac=16|abbr=yes}}}}
→ 1.57 m (5 ft 1 13⁄16 in)
Technical details
The following examples show how the template works:
ft & in
{{Infobox person/height/switch |{{{1|5 ft 2 in}}} |{{#invoke:String|replace|{{{1|5 ft 2 in}}}| | }} |m={{#invoke:String|find|{{#invoke:String|replace|{{{1|5 ft 2 in}}}| | }}|m}} |c={{#invoke:String|find|{{#invoke:String|replace|{{{1|5 ft 2 in}}}| | }}|cm}} |f={{#invoke:String|find|{{#invoke:String|replace|{{{1|5 ft 2 in}}}| | }}|ft}} |i={{#invoke:String|find|{{#invoke:String|replace|{{{1|5 ft 2 in}}}| | }}|in}} }}
Result:
{{Infobox person/height/switch
|5 ft 2 in
|5 ft 2 in
|m=0
|c=0
|f=3
|i=8
}}
cm
{{Infobox person/height/switch |{{{1|198 cm}}} |{{#invoke:String|replace|{{{1|198 cm}}}| | }} |m={{#invoke:String|find|{{#invoke:String|replace|{{{1|198 cm}}}| | }}|m}} |c={{#invoke:String|find|{{#invoke:String|replace|{{{1|198 cm}}}| | }}|cm}} |f={{#invoke:String|find|{{#invoke:String|replace|{{{1|198 cm}}}| | }}|ft}} |i={{#invoke:String|find|{{#invoke:String|replace|{{{1|198 cm}}}| | }}|in}} }}
Result:
{{Infobox person/height/switch
|198 cm
|198 cm
|m=6
|c=5
|f=0
|i=0
}}
m
{{Infobox person/height/switch |{{{1|1.98 m}}} |{{#invoke:String|replace|{{{1|1.98 m}}}| | }} |m={{#invoke:String|find|{{#invoke:String|replace|{{{1|1.98 m}}}| | }}|m}} |c={{#invoke:String|find|{{#invoke:String|replace|{{{1|1.98 m}}}| | }}|cm}} |f={{#invoke:String|find|{{#invoke:String|replace|{{{1|1.98 m}}}| | }}|ft}} |i={{#invoke:String|find|{{#invoke:String|replace|{{{1|1.98 m}}}| | }}|in}} }}
Result:
{{Infobox person/height/switch
|1.98 m
|1.98 m
|m=6
|c=0
|f=0
|i=0
}}
See also