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

Template:Infobox person/weight/locate

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

This is one of three templates used to automatically add conversions of weight measurements displayed by Template:Infobox person and other infoboxes with a |weight= parameter.

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

Contents

  • 1 Usage
  • 2 Exceptions
  • 3 Technical details
    • 3.1 kg
    • 3.2 lb
    • 3.3 st
    • 3.4 st/lb
  • 4 See also

Usage

  • {{Template:Infobox person/weight/locate|108 kg}} → 108 kg (238 lb)
  • {{Template:Infobox person/weight/locate|108&nbsp;kg}} → 108 kg (238 lb)
  • {{Template:Infobox person/weight/locate|238 lb}} → 238 lb (108 kg)
  • {{Template:Infobox person/weight/locate|238&nbsp;lb}} → 238 lb (108 kg)
  • {{Template:Infobox person/weight/locate|17 st}} → 17 st (238 lb; 108 kg)
  • {{Template:Infobox person/weight/locate|17&nbsp;st}} → 17 st (238 lb; 108 kg)
  • {{Template:Infobox person/weight/locate|108 kg (2012)}} → 108 kg (238 lb) (2012)
  • {{Template:Infobox person/weight/locate|108&nbsp;kg (2012)<ref>citation goes here</ref>}} → 108 kg (238 lb) (2012)[1]
  1. ^ citation goes here

Exceptions

Does not replace numbers in hard-coded conversions (examples intentionally show incorrect conversions):

  • {{Template:Infobox person/weight/locate|108 kg (229 lb)}} → 108 kg (229 lb)
  • {{Template:Infobox person/weight/locate|238 lb (119 kg)}} → 238 lb (119 kg)
  • {{Template:Infobox person/weight/locate|17 st (229 lb; 119 kg)}} → 17 st (229 lb; 119 kg)

Does not replace numeric output of conversion templates such as {{convert}} (examples have precision different than usual):

  • {{Template:Infobox person/weight/locate|{{convert|108|kg|lb|1|abbr=on}}}} → 108 kg (238.1 lb)
  • {{Template:Infobox person/weight/locate|{{convert|238|lb|kg|2|abbr=on}}}} → 238 lb (107.95 kg)
  • {{Template:Infobox person/weight/locate|{{convert|17|st|3|abbr=on}}}} → 17 st (238.000 lb; 107.955 kg)

Technical details

The following examples show how the template works:

kg

{{Infobox person/weight/switch
  |108&nbsp;kg
  |{{#invoke:String|replace|108&nbsp;kg|&nbsp;| }}
  |k={{#invoke:String|find|{{#invoke:String|replace|108&nbsp;kg|&nbsp;| }}|kg}}
  |s={{#invoke:String|find|{{#invoke:String|replace|108&nbsp;kg|&nbsp;| }}|st}}
  |l={{#invoke:String|find|{{#invoke:String|replace|108&nbsp;kg|&nbsp;| }}|lb}}
}}

Result:
{{Infobox person/weight/switch |108&nbsp;kg |108 kg |k=5 |s=0 |l=0 }}

lb

{{Infobox person/weight/switch
  |238&nbsp;lb
  |{{#invoke:String|replace|238&nbsp;lb|&nbsp;| }}
  |k={{#invoke:String|find|{{#invoke:String|replace|238&nbsp;lb|&nbsp;| }}|kg}}
  |s={{#invoke:String|find|{{#invoke:String|replace|238&nbsp;lb|&nbsp;| }}|st}}
  |l={{#invoke:String|find|{{#invoke:String|replace|238&nbsp;lb|&nbsp;| }}|lb}}
}}

Result:
{{Infobox person/weight/switch |238&nbsp;lb |238 lb |k=0 |s=0 |l=5 }}

st

{{Infobox person/weight/switch
  |17&nbsp;st
  |{{#invoke:String|replace|17&nbsp;st|&nbsp;| }}
  |k={{#invoke:String|find|{{#invoke:String|replace|17&nbsp;st|&nbsp;| }}|kg}}
  |s={{#invoke:String|find|{{#invoke:String|replace|17&nbsp;st|&nbsp;| }}|st}}
  |l={{#invoke:String|find|{{#invoke:String|replace|17&nbsp;st|&nbsp;| }}|lb}}
}}

Result:
{{Infobox person/weight/switch |17&nbsp;st |17 st |k=0 |s=4 |l=0 }}

st/lb

{{Infobox person/weight/switch
  |17&nbsp;st&nbsp;7&nbsp;lb
  |{{#invoke:String|replace|17&nbsp;st&nbsp;7&nbsp;lb|&nbsp;| }}
  |k={{#invoke:String|find|{{#invoke:String|replace|17&nbsp;st&nbsp;7&nbsp;lb|&nbsp;| }}|kg}}
  |s={{#invoke:String|find|{{#invoke:String|replace|17&nbsp;st&nbsp;7&nbsp;lb|&nbsp;| }}|st}}
  |l={{#invoke:String|find|{{#invoke:String|replace|17&nbsp;st&nbsp;7&nbsp;lb|&nbsp;| }}|lb}}
}}

Result:
{{Infobox person/weight/switch |17&nbsp;st&nbsp;7&nbsp;lb |17 st 7 lb |k=0 |s=4 |l=9 }}

See also

  • Template:Infobox person
  • Template:Infobox person/height
    • Template:Infobox person/height/locate
    • Template:Infobox person/height/switch
  • Template:Infobox person/length
    • Template:Infobox person/length/locate
    • Template:Infobox person/length/switch
The above documentation is transcluded from Template:Infobox person/weight/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/weight/locate&oldid=20241"
Category:
  • Template implementation details
Last edited on 12 August 2017, at 20:03

MOASSpedia

Content is available under Creative Commons Attribution-ShareAlike unless otherwise noted.
  • This page was last edited on 12 August 2017, at 20:03.
  • Content is available under Creative Commons Attribution-ShareAlike unless otherwise noted.
  • Privacy policy
  • About MOASSpedia
  • Disclaimers
  • Desktop