Template:Boolean: Difference between revisions

From Mainlining Wiki
Jump to navigation Jump to search
Knuxify (talk | contribs)
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\"..."
 
Knuxify (talk | contribs)
No edit summary
 
Line 1: Line 1:
<includeonly>{{#switch: {{lc: {{#if: {{{value|}}}|{{{value}}}|{{#if: {{{1|}}}|{{{1}}}|{{{default|false}}}}}}}}}
<includeonly>{{#switch: {{lc: {{#if: {{{value|}}}|{{{value}}}|{{#if: {{{1|}}}|{{{1}}}|{{{default|false}}}}}}}}}
|y|yes|true=true
|1|y|yes|t|true=true
|n|no|false=false
|0|n|no|f|false=false
|{{#if: {{{default-invalid|false}}}|{{{boolean|{{{default-invalid|false}}}}}}||}}
|{{#if: {{{default-invalid|false}}}|{{{boolean|{{{default-invalid|false}}}}}}||}}
}}</includeonly><!--
}}</includeonly><!--
Line 14: Line 14:
],
],
"label": "Value",
"label": "Value",
"description": "Value to turn into a boolean. \"y\", \"yes\" or \"true\" will turn into \"true\"; \"n\", \"no\" or \"false\" will turn into \"false\". Case insensitive.",
"description": "Value to turn into a boolean. \"1\", \"y\", \"yes\", \"t\" or \"true\" will turn into \"true\"; \"0\", \"n\", \"no\", \"f\" or \"false\" will turn into \"false\". Case insensitive.",
"type": "boolean",
"type": "boolean",
"suggested": true
"suggested": true
Line 31: Line 31:
}
}
},
},
"description": "Parse a boolean argument (\"y\", \"yes\", \"n\", \"no\", ...) and turn it into either \"true\" or \"false\".",
"description": "Parse a boolean argument (\"y\", \"yes\", \"1\", \"true\", \"t\"; \"n\", \"no\", \"0\", \"false\", \"f\") and turn it into either \"true\" or \"false\".",
"paramOrder": [
"paramOrder": [
"1",
"1",

Latest revision as of 07:45, 2 March 2025

Parse a boolean argument ("y", "yes", "1", "true", "t"; "n", "no", "0", "false", "f") and turn it into either "true" or "false".

Template parameters[Edit template data]

ParameterDescriptionTypeStatus
Value1 value

Value to turn into a boolean. "1", "y", "yes", "t" or "true" will turn into "true"; "0", "n", "no", "f" or "false" will turn into "false". Case insensitive.

Booleansuggested
Defaultdefault

Default value to fall back to if the passed value is empty. Accepts the same values as the value parameter.

Auto value
false
Booleanoptional
Default for invalid valuesdefault-invalid

Default value for invalid values. Accepts the same values as the "values" parameter, or an empty string.

Auto value
false
Booleanoptional

Examples

{{boolean|yes}} -> true

{{boolean|Yes}} -> true

{{boolean|N}} -> false

{{boolean||default=false}} -> false

{{boolean||default=yes}} -> true

{{boolean|asdf|default-invalid=invalid}} -> invalid