Content added Content deleted
Horblegorble (talk | contribs) No edit summary |
Horblegorble (talk | contribs) No edit summary |
||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<includeonly><!-- |
<includeonly><!-- |
||
-->{{#if:{{{1}}} |
-->{{#if: {{{1}}} |
||
| {{#switch: {{lc: {{{1}}} }} |
|||
| 1 = 1 |
| 1 = 1 |
||
| yes = 1 |
| yes = 1 |
||
| y = 1 |
|||
| true = 1 |
| true = 1 |
||
| t = 1 |
|||
| 0 = 0 |
| 0 = 0 |
||
| no = 0 |
| no = 0 |
||
| n = 0 |
|||
| false = 0 |
| false = 0 |
||
| f = 0 |
|||
| undefined |
| undefined |
||
}} |
}} |
||
Line 15: | Line 19: | ||
--><noinclude> |
--><noinclude> |
||
Case-insensitive conversion of 'truthy' and 'falsey' input to '1' or '0' |
Case-insensitive conversion of 'truthy' and 'falsey' input to '1' or '0'.<br> |
||
No input -> 'none'<br> |
No input -> 'none'<br> |
||
All other input -> 'undefined' |
All other input -> 'undefined' |
||
Intended for use in `#ifexpr` templates.<br> |
|||
e.g. <nowiki>{{#ifexpr: {{Bool | {{{input}}} }} | true | false }}</nowiki> |
|||
input-output table:<br> |
input-output table:<br> |
||
Line 27: | Line 27: | ||
! input !! output |
! input !! output |
||
|- |
|- |
||
| <nowiki>{{Bool|}}</nowiki> || {{ |
| <nowiki>{{Bool|}}</nowiki> || {{Bool|}} |
||
|- |
|||
| <nowiki>{{Bool|1}}</nowiki> || {{Bool|1}} |
|||
|- |
|||
| <nowiki>{{Bool|0}}</nowiki> || {{Bool|0}} |
|||
|- |
|||
||| |
|||
|- |
|||
| <nowiki>{{Bool|yes}}</nowiki> || {{Bool|yes}} |
|||
|- |
|||
| <nowiki>{{Bool|no}}</nowiki> || {{Bool|no}} |
|||
|- |
|- |
||
| <nowiki>{{Bool| |
| <nowiki>{{Bool|true}}</nowiki> || {{Bool|true}} |
||
|- |
|- |
||
| <nowiki>{{Bool| |
| <nowiki>{{Bool|false}}</nowiki> || {{Bool|false}} |
||
|- |
|- |
||
||| |
||| |
||
|- |
|- |
||
| <nowiki>{{Bool| |
| <nowiki>{{Bool|y}}</nowiki> || {{Bool|yes}} |
||
|- |
|- |
||
| <nowiki>{{Bool| |
| <nowiki>{{Bool|n}}</nowiki> || {{Bool|no}} |
||
|- |
|- |
||
| <nowiki>{{Bool| |
| <nowiki>{{Bool|t}}</nowiki> || {{Bool|true}} |
||
|- |
|- |
||
| <nowiki>{{Bool| |
| <nowiki>{{Bool|f}}</nowiki> || {{Bool|false}} |
||
|- |
|- |
||
||| |
||| |
Latest revision as of 00:13, 13 September 2023
Case-insensitive conversion of 'truthy' and 'falsey' input to '1' or '0'.
No input -> 'none'
All other input -> 'undefined'
input-output table:
input | output |
---|---|
{{Bool|}} | none |
{{Bool|1}} | 1 |
{{Bool|0}} | 0 |
{{Bool|yes}} | 1 |
{{Bool|no}} | 0 |
{{Bool|true}} | 1 |
{{Bool|false}} | 0 |
{{Bool|y}} | 1 |
{{Bool|n}} | 0 |
{{Bool|t}} | 1 |
{{Bool|f}} | 0 |
{{Bool|Yes}} | 1 |
{{Bool|YES}} | 1 |
{{Bool|No}} | 0 |
{{Bool|NO}} | 0 |
{{Bool|True}} | 1 |
{{Bool|TRUE}} | 1 |
{{Bool|False}} | 0 |
{{Bool|FALSE}} | 0 |
{{Bool| yes}} | 1 |
{{Bool|yes }} | 1 |
{{Bool| yes }} | 1 |
{{Bool|other}} | UNDEFINED |