User:Johan G/convert/rear: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
(Moving pretty much all but the conversion factors here)
m (Minor fixes in comments and error messages)
 
Line 1: Line 1:
{{#if: <!-- Is the "value" parameter missing? -->
{{#if: <!-- Is the "expression" parameter missing? -->
   {{{1|}}}
   {{{1|}}}
   | <!-- No, the "to-unit" parameter is not missing
   | <!-- No, the "expression" parameter is not missing
     -->{{#if: <!-- Is the to-unit parameter missing? -->
     -->{{#if: <!-- Is the "to-unit" parameter missing? -->
       {{{2|}}}
       {{{2|}}}
       | <!-- No, the to-unit parameter is not missing
       | <!-- No, the "to-unit" parameter is not missing
         -->{{#expr: {{{1|1000 div 25.4}}} round  
         -->{{#expr: {{{1|1000 div 25.4}}} round  
           {{#ifeq: <!-- Is "decimals" an empty string? -->
           {{#ifeq: <!-- Is "decimals" an empty string? -->
Line 21: Line 21:
         {{error|<nowiki>{{User:Johan G/convert/pds}}</nowiki>: Parameter '''to-unit''' missing}}
         {{error|<nowiki>{{User:Johan G/convert/pds}}</nowiki>: Parameter '''to-unit''' missing}}
     }}
     }}
   | <!-- Yes, the "value" parameter is missing. Throw an error -->
   | <!-- Yes, the "expression" parameter is missing. Throw an error -->
     {{error|<nowiki>{{User:Johan G/convert/pds}}</nowiki>: Parameter '''value''' missing}}
     {{error|<nowiki>{{User:Johan G/convert/rear}}</nowiki>: Parameter '''expression''' missing}}
}}<noinclude>
}}<noinclude>
{{Informative template|1=
{{Informative template|1=

Latest revision as of 19:10, 6 August 2018

{{User:Johan G/convert/rear}}: Parameter expression missing

The following template description is not displayed when the template is inserted in an article.

Goal

This template handles rounding, decimals and units for User:Johan G/convert ("rear" is for rear part of the quantity).


Note When this template draft is moved to the template namespace, give it a better name...

Usage

{{User:Johan G/convert/rear|expression|to-unit|decimals|hide-unit}}

The parameters expression and to-unit is manatory, though all parameters should be passed from the main template.

expression
Expression to be calculated with Extension:ParserFunctions's #expr function
to-unit
Unit to be converted to
decimals
Number of decimals. If empty, no decimals will be shown
hide-unit
If not empty the unit will not be shown in the result

Examples

Conversion from millimeters to inches as it would be used in the main template...

{{User:Johan G/convert/rear|{{{1}}} div 25.4|in|{{{4|}}}|{{{5|}}}}}

...with the parameters having these values

{{User:Johan G/convert/rear|1000 div 25.4|in|2|}}

39.37 in

Known issues

Trailing zeros in the decimals will not be shown.

Related templates