Template:Convert/doc: Difference between revisions

From Wikishire
Jump to navigation Jump to search
Created page with '{{Documentation subpage}} '''THIS DOES NOT WORK YET BUT WE ARE GETTING THERE''' The Template will convert between units of measurement. The basic format is: <nowiki>{{</nowik…'
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{Documentation subpage}}
{{Documentation subpage}}
'''THIS DOES NOT WORK YET BUT WE ARE GETTING THERE'''


The Template will convert between units of measurement.  The basic format is:
The '''Convert''' template converts between units of measurement.  The basic format is:


  <nowiki>{{</nowiki>convert | [value] | [unit] | [unit to convert to] | [how many decimal places] <nowiki>}}</nowiki>
  <nowiki>{{</nowiki>convert | [value] | [unit] | [unit to convert to] | [how many decimal places] <nowiki>}}</nowiki>


The third and fourth elements (the "output unit" and the rounding figure) may be omitted, in which case the programme will choose a normal counterpart for the input unit and will assume all is rounded to 1 decimal place.
The third and fourth elements (the "output unit" and the rounding figure) may be omitted, in which case the template will choose from the database a normal counterpart for the input unit and will assume all is rounded to 1 decimal place.


{|
{|
|Thus || '''<nowiki>{{convert|1,000|ft}}</nowiki>
|Thus || '''<nowiki>{{convert|1,000|ft}}</nowiki>
|-
|-
| will produce: || 1,000 feet (304.8 m)
| will produce: || {{convert|1,000|ft}}
|}
|}


If one of the units is imperial, the programme will always put that one first.
If one of the units is imperial, the programme will always put that one first.


[[Category:Convert templates|Convert]]
==Units==
The system accepts a wide range of units and while there are codes for them, the template is worked so that any reasonable and unambiguous rendering of the name of the unit, if we have anticipated it, will be accepted (so a metre is "m", but entering "m", "metre" or "metres" for it will work too).
 
==Additional, optional codes==
There are two short codes, for rounding and the "x" code, which may be added after the unit or units.  It does not matter which way round these go, as long as they are in a distinct field ("|3" or "|x").
 
===Rounding===
To chose the number of decimal places to which the answer should be rounded, add the number after the unit(s).
 
==Imperial only:  ''x'' code==
If the non-imperial measurement is to be omitted (for example if the original material has metric only but you want to show an imperial unit in its place), add "x" after the unit(s):
 
{|
|Putting || '''<nowiki>{{convert|300|m|x}}</nowiki>''' || '''<nowiki>{{convert|300|m|3}}</nowiki>'''
|-
| will produce: || {{convert|300|m|x}} || {{convert|300|m|3}}
|-
|Likewise || COLSPAN="2"|'''<nowiki>{{convert|300|m|x|2}}</nowiki>''' or '''<nowiki>{{convert|300|m|2|x}}</nowiki>'''
|-
| will produce: || {{convert|300|m|x|2}}
|}
 
==Missing units==
If there are useful units which do not work in the template, it is only a question of updating the database:  notify the Wikishire folk on the Talk page and someone will no doubt sort it out.
 
<includeonly>[[Category:Convert templates|Convert]]

Latest revision as of 13:18, 12 October 2012

Template:Mbox

The Convert template converts between units of measurement. The basic format is:

{{convert | [value] | [unit] | [unit to convert to] | [how many decimal places] }}

The third and fourth elements (the "output unit" and the rounding figure) may be omitted, in which case the template will choose from the database a normal counterpart for the input unit and will assume all is rounded to 1 decimal place.

Thus {{convert|1,000|ft}}
will produce: 1,000.0 feet (304.8 m)

If one of the units is imperial, the programme will always put that one first.

Units

The system accepts a wide range of units and while there are codes for them, the template is worked so that any reasonable and unambiguous rendering of the name of the unit, if we have anticipated it, will be accepted (so a metre is "m", but entering "m", "metre" or "metres" for it will work too).

Additional, optional codes

There are two short codes, for rounding and the "x" code, which may be added after the unit or units. It does not matter which way round these go, as long as they are in a distinct field ("|3" or "|x").

Rounding

To chose the number of decimal places to which the answer should be rounded, add the number after the unit(s).

Imperial only: x code

If the non-imperial measurement is to be omitted (for example if the original material has metric only but you want to show an imperial unit in its place), add "x" after the unit(s):

Putting {{convert|300|m|x}} {{convert|300|m|3}}
will produce: 984.3 feet 984.252 feet (300.000 m)
Likewise {{convert|300|m|x|2}} or {{convert|300|m|2|x}}
will produce: 984.25 feet

Missing units

If there are useful units which do not work in the template, it is only a question of updating the database: notify the Wikishire folk on the Talk page and someone will no doubt sort it out.