• Home
  • Random
  • Recent changes
  • Special pages
  • Settings
  • About MOASSpedia
  • Disclaimers
MOASSpedia
  • 216.73.216.49
  • Talk
  • Watchlist
  • Contributions
  • Log in

Template:Infobox person/height/locate

Template Discussion
  • Language
  • Watch
  • History
  • Edit
    • Page information
    • Permanent link
    • What links here
< Template:Infobox person‎ | height
Template documentation[view] [edit] [history] [purge]

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.

  1. Template:Infobox person/height changes text for units of height to the abbreviations "m", "cm", "ft", or "in", then passes the string to:
  2. Template:Infobox person/height/locate which replaces any instances of &nbsp; with a space, and determines the positions of "m", "cm", "ft", or "in" within that string, all of which is passed to:
  3. Template:Infobox person/height/switch which does the conversion

Contents

  • 1 Usage
  • 2 Exceptions
  • 3 Technical details
    • 3.1 ft & in
    • 3.2 cm
    • 3.3 m
  • 4 See also

Usage

  • {{Template:Infobox person/height/locate|1.57 m}} → 1.57 m (5 ft 2 in)
  • {{Template:Infobox person/height/locate|1.57&nbsp;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&nbsp;cm}} → 157 cm (5 ft 2 in)
  • {{Template:Infobox person/height/locate|5 ft}} → 5 ft (152 cm)
  • {{Template:Infobox person/height/locate|5&nbsp;ft}} → 5 ft (152 cm)
  • {{Template:Infobox person/height/locate|2 in}} → 2 in (5 cm)
  • {{Template:Infobox person/height/locate|2&nbsp;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&nbsp;ft 2&nbsp;in}} → 5 ft 2 in (157 cm)
  • {{Template:Infobox person/height/locate|5&nbsp;ft 2&nbsp;in (2012)}} → 5 ft 2 in (157 cm) (2012)
  • {{Template:Infobox person/height/locate|5&nbsp;ft 2&nbsp;in (2012)<ref>citation goes here</ref>}} → 5 ft 2 in (157 cm) (2012)[1]
  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&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}}
}}

Result:
{{Infobox person/height/switch |5 ft 2&nbsp;in |5 ft 2 in |m=0 |c=0 |f=3 |i=8 }}

cm

{{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}}
}}

Result:
{{Infobox person/height/switch |198&nbsp;cm |198 cm |m=6 |c=5 |f=0 |i=0 }}

m

{{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}}
}}

Result:
{{Infobox person/height/switch |1.98&nbsp;m |1.98 m |m=6 |c=0 |f=0 |i=0 }}

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
The above documentation is transcluded from Template:Infobox person/height/locate/doc. (edit | history)
Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages.
Add categories to the /doc subpage. Subpages of this template.
Retrieved from "https://moasspedia.org/w/index.php?title=Template:Infobox_person/height/locate&oldid=20228"
Category:
  • Template implementation details
Last edited on 2 July 2015, at 22:27

MOASSpedia

Content is available under Creative Commons Attribution-ShareAlike unless otherwise noted.
  • This page was last edited on 2 July 2015, at 22:27.
  • Content is available under Creative Commons Attribution-ShareAlike unless otherwise noted.
  • Privacy policy
  • About MOASSpedia
  • Disclaimers
  • Desktop