Predloga:Infopolje Oseba/višina/locate/dok

Iz Wikipedije, proste enciklopedije

Predloga:Infopolje Oseba/višina/locate is one of three templates used to automatically add conversions of height measurements displayed by Predloga:Infopolje Oseba and other infoboxes with a |height= parameter.

  1. Predloga:Infopolje Oseba/višina changes text for units of height to the abbreviations "m", "cm", "ft", or "in", then passes the string to:
  2. Predloga:Infopolje Oseba/višina/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:
  3. Predloga:Infopolje Oseba/višina/switch which does the conversion

Usage[uredi kodo]

  • {{Predloga:Infopolje Oseba/višina/locate|1.57 m}} → 157 m
  • {{Predloga:Infopolje Oseba/višina/locate|1.57 m}} → 157 m
  • {{Predloga:Infopolje Oseba/višina/locate|157 cm}} → 157 cm
  • {{Predloga:Infopolje Oseba/višina/locate|157 cm}} → 157 cm
  • {{Predloga:Infopolje Oseba/višina/locate|5 ft}} → 152 cm
  • {{Predloga:Infopolje Oseba/višina/locate|5 ft}} → 152 cm
  • {{Predloga:Infopolje Oseba/višina/locate|2 in}} → 5 cm
  • {{Predloga:Infopolje Oseba/višina/locate|2 in}} → 5 cm
  • {{Predloga:Infopolje Oseba/višina/locate|5 ft 2 in}} → 157 cm
  • {{Predloga:Infopolje Oseba/višina/locate|5 ft 2 in}} → 157 cm
  • {{Predloga:Infopolje Oseba/višina/locate|5 ft 2 in (2012)}} → 157 cm (2012)
  • {{Predloga:Infopolje Oseba/višina/locate|5&nbsp;ft 2&nbsp;in (2012)<ref>citation goes here</ref>}} → 157 cm (2012)[1]
  1. citation goes here

Exceptions[uredi kodo]

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

  • {{Predloga:Infopolje Oseba/višina/locate|5 ft 2 in (100 cm)}} → 5 ft 2 in (100 cm)
  • {{Predloga:Infopolje Oseba/višina/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):

  • {{Predloga:Infopolje Oseba/višina/locate|{{convert|5|ft|2|in|m|3|abbr=on}}}} → 5 ft 2 in (1,575 m)
  • {{Predloga:Infopolje Oseba/višina/locate|{{convert|1.57|m|ftin|1|abbr=on}}}} → 157 m (515 ft 1,1 in)
  • {{Predloga:Infopolje Oseba/višina/locate|{{height|ft=5|in=2|precision=3|abbr=yes}}}} → 5 ft 2 in (1,575 m)
  • {{Predloga:Infopolje Oseba/višina/locate|{{height|m=1.57|frac=16|abbr=yes}}}} → 1,57 m (5 ft 1+Napaka v izrazu: Nepričakovan operator <.Napaka v izrazu: Nepričakovan operator <. in)

Technical details[uredi kodo]

The following example shows how the template works:

{{Infopolje Oseba/višina/switch
  |{{{1|5 ft 2&nbsp;in}}}
  |{{#invoke:Niz|replace|{{{1|5 ft 2&nbsp;in}}}|&nbsp;| }}
  |m={{#invoke:Niz|find|{{#invoke:Niz|replace|{{{1|5 ft 2&nbsp;in}}}|&nbsp;| }}|m}}
  |c={{#invoke:Niz|find|{{#invoke:Niz|replace|{{{1|5 ft 2&nbsp;in}}}|&nbsp;| }}|cm}}
  |f={{#invoke:Niz|find|{{#invoke:Niz|replace|{{{1|5 ft 2&nbsp;in}}}|&nbsp;| }}|ft}}
  |i={{#invoke:Niz|find|{{#invoke:Niz|replace|{{{1|5 ft 2&nbsp;in}}}|&nbsp;| }}|in}}
}}

Result:
{{Infopolje Oseba/višina/switch |5 ft 2&nbsp;in |5 ft 2 in |m=0 |c=0 |f=3 |i=8 }}

See also[uredi kodo]