→top: {{{value|}}} comes as zero not blank (thanks User:Christian75!)
細 (1版) |
bsd>DMacks (→top: {{{value|}}} comes as zero not blank (thanks User:Christian75!)) |
||
1行目: | 1行目: | ||
{{#iferror:{{{value|}}}|{{#if:{{{fixed|}}}|{{{fixed|}}}|<sup class="noprint Inline-Template" style="white-space:nowrap;">[ | {{#if:{{{fixed|}}}|{{#ifexpr:{{{value|}}}>0|[[Category:Chem-molar-mass both hardcoded and calculated]]}}}}{{#iferror:{{{value|}}}<!-- | ||
iferror: true | |||
-->|{{#if:{{{fixed|}}}|<!-- error in fixed, return as is: -->{{{fixed|}}}|<!-- error is in calculation: --><sup class="noprint Inline-Template" style="white-space:nowrap;">[''[[Wikipedia:WikiProject Chemicals/Molar mass#Cannot calculate molar mass|<span title="Cannot calculate molar mass from chemical formula)">cannot calculate</span>]]'']</sup>}}{{main other|[[Category:Articles with erroneous molar mass calculations]]}}<!-- | |||
-->|{{#ifeq:{{{ | iferror:false | ||
|{{{ | prefix: hidden sortkey ntsh | ||
|{{#invoke: | buggy: this way, sorted is the non-rounded value... | ||
-->|{{#ifeq:{{{sortable|no}}}|yes|{{ntsh|1={{#if:{{{fixed|}}}|{{#invoke:String|match|s={{{fixed|}}} |pattern=^[%d%.%-%−]+ |plain=false |nomatch={{{fixed|0}}}}} |{{{value|0}}} }} |debug=no<!-- set to =yes to test/show the hidden key -->}} }}<!-- | |||
round the value: | |||
parameter round can be: yes, no, smart, number. | |||
rounding number cannot be greater than smart (=smart number of decimals), so use min(,). | |||
smart number cannot be empty, but is covered with "|2" here | |||
--> | -->{{#if:{{{fixed|}}}|{{{fixed|}}}| | ||
{{#ifexpr:{{{value|0}}}=0|<!-- no input, no value output -->|{{val|{{#invoke:math|precision_format |{{{value|0}}} | |||
-->{{ | |{{#switch:{{{round|smart}}} | ||
|yes={{min|2|{{{smart_round|2}}}}}<!-- min(2, smart) --> | |||
|no={{{smart_round|2}}}<!-- smart --> | |||
||default|smart={{{smart_round|2}}} | |||
|{{{ | |#default={{min|{{{round|0}}}|{{{smart_round|2}}}}}<!-- when number; min(number, smart) -->}} | ||
|{{ | }} }} }} }}<!-- | ||
-->}} }} }}<!-- | |||
iferror: close | |||
-->}}<!-- | |||
suffix: if sort=no then add unit | |||
-->{{#ifexpr:{{{value|0}}}=0||{{#ifeq:|{{{sortable|unk}}}|no| {{#if:{{{unit|}}} |{{{unit|}}}|g·mol<sup>−1</sup>}}}}}}<!-- | |||
suffixes, will always show: | suffixes, will always show: | ||
-->{{{ref|}}}{{#if:{{{comment|}}}| {{{comment|}}}}}<!-- | -->{{{ref|}}}{{#if:{{{comment|}}}| {{{comment|}}}}}<!-- | ||
</noinclude> | |||
-xxx-> <small>(debug:smart_round={{{smart_round|(blank)}}})</small><!-- | |||
--><noinclude>{{documentation|1=Template:Chem molar mass/doc}}</noinclude> |