Template:Bool

From Sword of Moonlight Wiki
Revision as of 19:56, 13 September 2024 by Verdite cat (talk | contribs) (Created page with "<includeonly>{{#switch:{{lc:{{{1|}}}}}|y|1|yes|true=y|#default={{#if:{{{1|}}}||{{{2|}}}}}}}</includeonly><noinclude>{{doc}}</noinclude>")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Template documentation follows
Note: the template above may sometimes be partially or fully invisible.
Visit Template:Bool/doc to edit this documentation. (How does this work?)

This simple helper template will display y if its input is y, yes, true, or 1. It will not display anything otherwise. The empty input is special, you can change its behavior via unnamed parameter 2, see examples below. This is useful for handle revert flag option parameters, such as |link=no, which empty input means "true".

This functionality is useful for templates where a parameter should only have an effect if it is set to one of these positive values. It is especially helpful for the integration of TemplateData, which sets a parameter that is marked as Boolean to 0 if it is added and de-selected.

Usage

{ bool | <string> | <value for empty input> ]

First unnamed parameter

The input string to check.

Examples

Code Result
{{bool|y}} y
{{bool|yes}} y
{{bool|true}} y
{{bool|1}} y
{{bool|n}}
{{bool|no}}
{{bool|false}}
{{bool|0}}
{{bool|foo}}
{{bool|}}
{{bool||y}} y
{{bool|2=y}} y
{{[[Template:#if:{{bool|{{{format|yes}}}}}|#if:{{bool|{{{format|yes}}}}}]]|format|don't format}} format
{{[[Template:#if:{{bool|{{{format|false}}}}}|#if:{{bool|{{{format|false}}}}}]]|format|don't format}} don't format