Template:Boolean: Difference between revisions
Jump to navigation
Jump to search
Created page with "<includeonly>{{#switch: {{lc: {{#if: {{{value|}}}|{{{value}}}|{{#if: {{{1|}}}|{{{1}}}|{{{default|false}}}}}}}}} |y|yes|true=true |n|no|false=false |{{#if: {{{default-invalid|false}}}|{{{boolean|{{{default-invalid|false}}}}}}||}} }}</includeonly><!-- --><noinclude> <templatedata> { "params": { "1": { "aliases": [ "value" ], "label": "Value", "description": "Value to turn into a boolean. \"y\", \"yes\" or \"true\" will turn into \"true\"; \"n\", \"no\"..." |
(No difference)
|
Revision as of 07:42, 2 March 2025
Parse a boolean argument ("y", "yes", "n", "no", ...) and turn it into either "true" or "false".
Parameter | Description | Type | Status | |
---|---|---|---|---|
Value | 1 value | Value to turn into a boolean. "y", "yes" or "true" will turn into "true"; "n", "no" or "false" will turn into "false". Case insensitive. | Boolean | suggested |
Default | default | Default value to fall back to if the passed value is empty. Accepts the same values as the value parameter.
| Boolean | optional |
Default for invalid values | default-invalid | Default value for invalid values. Accepts the same values as the "values" parameter, or an empty string.
| Boolean | optional |
Examples
{{boolean|yes}}
-> true
{{boolean|Yes}}
-> true
{{boolean|N}}
-> false
{{boolean||default=false}}
-> false
{{boolean||default=yes}}
-> true
{{boolean|asdf|default-invalid=invalid}}
-> invalid