Template:Convert

From RabastorWiki
Jump to navigation Jump to search

The available units are listed here. Note that units are case-sensitive!

Usage

This template calculates measurements from one unit (you can enter) to another one, and then presents the results. For example:

{{convert|2|km|mi}}Lua error: Cannot create process: proc_open(/home4/iltornan/lua/error.log): Failed to open stream: No such file or directory
{{convert|7|mi|km}}Lua error: Cannot create process: proc_open(/home4/iltornan/lua/error.log): Failed to open stream: No such file or directory

You can also round the result. Using round=5 for example, rounds the outcome to a multiple of 5.

{{convert|10|m|ft}}Lua error: Cannot create process: proc_open(/home4/iltornan/lua/error.log): Failed to open stream: No such file or directory
{{convert|10|m|ft|round=5}}Lua error: Cannot create process: proc_open(/home4/iltornan/lua/error.log): Failed to open stream: No such file or directory

In a range, one can round each value individually to the default. Use round=each:

{{convert|10 x 200 x 3000|m|ft}}Lua error: Cannot create process: proc_open(/home4/iltornan/lua/error.log): Failed to open stream: No such file or directory
{{convert|10 x 200 x 3000|m|ft|round=each}}Lua error: Cannot create process: proc_open(/home4/iltornan/lua/error.log): Failed to open stream: No such file or directory

Rounding to fractions is also possible. Specify the desired denominator using frac=<some positive integer>.

{{convert|5.56|cm|in|frac=16}}Lua error: Cannot create process: proc_open(/home4/iltornan/lua/error.log): Failed to open stream: No such file or directory
{{convert|8|cm|in|frac=4}}Lua error: Cannot create process: proc_open(/home4/iltornan/lua/error.log): Failed to open stream: No such file or directory

The fraction is reduced when possible:

{{convert|8|cm|in|frac=100}}Lua error: Cannot create process: proc_open(/home4/iltornan/lua/error.log): Failed to open stream: No such file or directory
{{convert|8|cm|in}}Lua error: Cannot create process: proc_open(/home4/iltornan/lua/error.log): Failed to open stream: No such file or directory (To compare)

While it is possible to enter feet, inch in a simple conversion, this is not possible for ranges:

  • {{convert|1|ft|3|in|mm}}Lua error: Cannot create process: proc_open(/home4/iltornan/lua/error.log): Failed to open stream: No such file or directory (to compare)
  • {{convert|1|ft|3|in|x|3|ft|5|in|mm}}Lua error: Cannot create process: proc_open(/home4/iltornan/lua/error.log): Failed to open stream: No such file or directory

In input, a comma for thousands separator is accepted but not required; a gap (space) is not accepted. In output, by default, the thousand separator is the comma:

  • {{convert|1234567|m|ft}}Lua error: Cannot create process: proc_open(/home4/iltornan/lua/error.log): Failed to open stream: No such file or directory
  • {{convert|1,234,567|m|ft}}Lua error: Cannot create process: proc_open(/home4/iltornan/lua/error.log): Failed to open stream: No such file or directory
  • {{convert|1 234 567|m|ft}}Lua error: Cannot create process: proc_open(/home4/iltornan/lua/error.log): Failed to open stream: No such file or directory

It is also possible to change the way the two measurements are distinguished from one another. Options are: b (the default), sqbr, comma, or, br, x|...:

{{convert|10|m|ft}}Lua error: Cannot create process: proc_open(/home4/iltornan/lua/error.log): Failed to open stream: No such file or directory( ) brackets are the default
{{convert|10|m|ft|disp=sqbr}}Lua error: Cannot create process: proc_open(/home4/iltornan/lua/error.log): Failed to open stream: No such file or directory
{{convert|10|m|ft|disp=comma}}Lua error: Cannot create process: proc_open(/home4/iltornan/lua/error.log): Failed to open stream: No such file or directory
{{convert|10|m|ft|disp=or}}Lua error: Cannot create process: proc_open(/home4/iltornan/lua/error.log): Failed to open stream: No such file or directory

Setting |disp=br will force a new line (<br>)

{{convert|10|m|ft|disp=br}}Lua error: Cannot create process: proc_open(/home4/iltornan/lua/error.log): Failed to open stream: No such file or directory

Also |disp=br() will force a new line, and keep the brackets:

{{convert|10|m|ft|disp=br()}}Lua error: Cannot create process: proc_open(/home4/iltornan/lua/error.log): Failed to open stream: No such file or directory

Use sortable=on to include a hidden numerical sortkey in the output, suitable for use in a table with sortable columns. Technically, this places a hidden string before the actual displayed values:

{{convert|10|m|ft|sortable=on}} → {{nowrap|1=<span style="display:none">7001100000000000000</span>10 metres (33&nbsp;ft)}