Discord-logo.jpg Join our Discord!
If you have been locked out of your account you can request a password reset here.

Difference between revisions of "Template:Convert"

From Internet Movie Firearms Database - Guns in Movies, TV and Video Games
Jump to navigation Jump to search
Line 1: Line 1:
<noinclude>This tempalte allows for an easy way to convert units. To use the template place <nowiki>{{convert|</nowiki>'''Value 1'''|'''Value 2'''<nowiki>}}</nowiki>
+
<includeonly>{{#ifeq: {{{1}}}|lbs|{{convert/lbs|{{Str number dp/trim|{{{2}}} }}|{{remove first word/any|{{title without disambig|{{{2}}}}}}}}}{{space}}{{#if:{{Title disambig text|{{{2}}}}}|({{Title disambig text|{{{2}}}}})}}}}{{#ifeq: {{{1}}}|in|{{convert/in|{{Str number dp/trim|{{{2}}} }}|{{remove first word/any|{{title without disambig|{{{2}}}}}}}}}{{space}}{{#if:{{Title disambig text|{{{2}}}}}|({{Title disambig text|{{{2}}}}})}}}}</includeonly><noinclude>
The first value given to the template, indicates what unit you are supplying (acceptable values are kg, lbs, g, oz, in, cm, mm). The Second parameter is the value you want to convert.
+
{{documentation}}
=Examples=
 
==Ex 1==
 
<div style="width: 400px; font-size:125%;"><pre>
 
* '''Weight''': {{convert|kg|5}}
 
</pre></div>
 
Produces:
 
* '''Weight''': {{convert|kg|5}}
 
==Ex 2==
 
<div style="width: 400px; font-size:125%;"><pre>
 
* '''Weight''': {{convert|oz|25}}
 
</pre></div>
 
Produces:
 
* '''Weight''': {{convert|oz|25}}
 
==Ex 3==
 
<div style="width: 400px; font-size:125%;"><pre>
 
* '''Barrel Length''': {{convert|in|5}}
 
</pre></div>
 
Produces:
 
* '''Barrel Length''': {{convert|in|5}}
 
==Ex 4==
 
<div style="width: 400px; font-size:125%;"><pre>
 
* '''Barrel Length''': {{convert|cm|25.1}}
 
</pre></div>
 
Produces:
 
* '''Barrel Length''': {{convert|cm|25.1}}
 
  
==Ex 5==
+
<!--{{#ifeq: {{{1}}}|in|{{convert/in|{{Str number dp/trim|{{{2}}} }}|{{remove first word/any|{{{2}}}}}}}}}-->
If the parameter supplied is invalid (such as '''ccm''' no output will be displayed)
 
<div style="width: 400px; font-size:125%;"><pre>
 
* '''Barrel Length''': {{convert|ccm|25}}
 
</pre></div>
 
Produces:
 
* '''Barrel Length''': {{convert|ccm|25}}
 
 
 
 
 
[[Category:Templates]]
 
<!-- ALL LINE BREAKS MUST BE REMOVED FOR TEMPLATE TO PROPERLY WORK!!!!! -->
 
</noinclude><includeonly><!-- kg to lbs -->{{#ifeq: {{{1}}}|kg|{{#expr: ({{{2}}}* 2.2046)round1}} lbs ({{#expr: ({{{2}}})round1}} kg)|}}<!-- lbs to kg -->{{#ifeq: {{{1}}}|lbs|{{#expr: ({{{2}}})round1}} lbs ({{#expr: ({{{2}}}* 0.45359)round1}} kg)|}}<!-- oz to kg & lbs -->{{#ifeq: {{{1}}}|oz|{{#expr: ({{{2}}}* 0.0625)round1}} lbs ({{#expr: ({{{2}}}* 0.0283495231)round1}} kg)|}}<!-- g to kg & lbs -->{{#ifeq: {{{1}}}|g|{{#expr: ({{{2}}}* 0.00220462262)round1}} lbs ({{#expr: ({{{2}}}* 0.001)round1}} kg)|}}<!-- in to cm-->{{#ifeq: {{{1}}}|in|{{#expr: ({{{2}}})round1}} in ({{#expr: ({{{2}}}* 2.54)round1}} cm)|}}<!-- cm to in-->{{#ifeq: {{{1}}}|cm|{{#expr: ({{{2}}}* 0.393700787)round1}} in ({{#expr: ({{{2}}})round1}} cm)|}}<!-- mm to in & cm-->{{#ifeq: {{{1}}}|mm|{{#expr: ({{{2}}}* 0.0393700787)round1}} in ({{#expr: ({{{2}}}* 0.1)round1}} cm)|}}</includeonly>
 

Revision as of 17:03, 29 August 2012

[edit] [history] Documentation icon Template documentation

Subtemplates

Template Type Output Units Accepted Units
{{convert/lbs}} weight lbs, kg lbs, kg, g, oz
{{convert/in}} length in, cm in, ft, m, cm, mm
{{convert/ft}} length ft, m in, ft, m, cm, mm

Examples

{{convert}}

{{convert/lbs}}

  • {{convert/lbs|456|lbs}} → 456 lbs (207 kg)
  • {{convert/lbs|207|kg}} → 456 lbs (207 kg)
  • {{convert/lbs|7296|oz}} → 456 lbs (207 kg)
  • {{convert/lbs|206838|g}} → 456 lbs (207 kg)

{{convert/in}}

  • {{convert/in|5|in}} → 5 in (13 cm)
  • {{convert/in|12.7|cm}} → 5 in (13 cm)
  • {{convert/in|127|mm}} → 5 in (13 cm)
  • {{convert/in|0.416667|ft}} → 5 in (13 cm)
  • {{convert/in|0.127|m}} → 5 in (13 cm)





Do Not Sell My Personal Information