Template:SanitiseBoolean: Difference between revisions
Appearance
AndrewSayers (talk | contribs) No edit summary |
AndrewSayers (talk | contribs) No edit summary |
||
| Line 10: | Line 10: | ||
| true | | true | ||
| enabled = 1 | | enabled = 1 | ||
| {{#if:{{ | | {{#if:{{MaybeBoolean|{{{IgnoreInvalid|0}}}}}||[[Category:Pages with invalid booleans]]|}}}} | ||
}}</onlyinclude></pre> | }}</onlyinclude></pre> | ||
<templatedata> | <templatedata> | ||
| Line 33: | Line 33: | ||
}, | }, | ||
"IgnoreInvalid": { | "IgnoreInvalid": { | ||
"description": "If | "label": "Ignore invalid?", | ||
"type": "boolean", | |||
"required": false, | |||
"default": "false", | |||
"description": "If the parameter is invalid parameter, do not add this page to the \"Pages with invalid booleans\" category." | |||
} | |||
}, | }, | ||
"description": "Convert boolean-like parameters (\"no\", \"true\" etc.) to 0 or 1, convert unknown values to the empty string. Please call this from other templates to sanitise your boolean values." | "description": "Convert boolean-like parameters (\"no\", \"true\" etc.) to 0 or 1, convert unknown values to the empty string. Please call this from other templates to sanitise your boolean values." | ||
Revision as of 16:40, 21 February 2026
<onlyinclude>{{#switch: {{lc:{{{1|}}}}}
| 0
| no
| off
| false
| disabled = 0
| 1
| on
| yes
| true
| enabled = 1
| {{#if:{{MaybeBoolean|{{{IgnoreInvalid|0}}}}}||[[Category:Pages with invalid booleans]]|}}}}
}}</onlyinclude>
Convert boolean-like parameters ("no", "true" etc.) to 0 or 1, convert unknown values to the empty string. Please call this from other templates to sanitise your boolean values.
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| Value | 1 | Value to convert to a boolean
| Unknown | required |
| Ignore invalid? | IgnoreInvalid | If the parameter is invalid parameter, do not add this page to the "Pages with invalid booleans" category.
| Boolean | optional |