no
Plantilla:High-use Plantilla:Tlx (or Plantilla:Tlg) evaluates any input and produces a normalized yes or nil output, based on the content of the input and several configurable options. It is not used in article prose, but in coding complex templates.
Usage
The template distinguishes five different types of input, supplied on the first unnamed parameter:
- Yes: Case-insensitive forms of
Yes
,y
,true
,on
, and1
; e.g. Plantilla:Tlx - No: Case-insensitive forms of
No
,n
,false
,off
, and0
; e.g. Plantilla:Tlx - Nothing: When the input is defined but either contains no value or consists of whitespace character only; i.e.
{{Yesno|}}
or Plantilla:Tlx - Negation: When the input is either
¬
or entirely missing; i.e. Plantilla:Tlx or Plantilla:Tlx - Anything else: e.g. Plantilla:Tlx
By default, the template returns "yes" in the first and last case but returns nil (blank, empty string) in the other cases.
Two short-hand templates for the most common uses that override the default behavior:
- Plantilla:Tlx or Plantilla:Tlg – always returns "yes" (or the specified replacement result in
|yes=
) unless an explicit negative value is given; i.e., it evaluates to "yes" even when the value is empty or missing.
- Plantilla:Tlx or Plantilla:Tlg – always returns "no" (or the specified replacement result in
|no=
) unless an explicit positive value is given; i.e., it evaluates to "no" even when the value is present, as long as it does not contain anything that resolves to "yes".
Customizing the output
Template's default output can be customized with five named parameters, respectively: |yes=
, |no=
, |blank=
, |¬=
and |def=
. If these parameters are specified, the template response is as follows:
- Yes: Template returns the contents of
|yes=
, otherwise returns "yes". For example:
- Plantilla:Tlx results in "Yeah"
- Plantilla:Tlx results in "bacon"
- No: Template returns the contents of
|no=
, otherwise returns blank. For example:
- Plantilla:Tlx results in "Nay"
- Plantilla:Tlx results in "ham"
- Nothing: Template returns the contents of
|blank=
, or of |no=
in absence of the former; otherwise, returns blank.
- Plantilla:Tlx results in "eggs"
- Plantilla:Tlx results in "ham"
- Plantilla:Tlx results in "eggs"
- Negation: Template returns the contents of
|¬=
, otherwise returns blank. For example:
- Plantilla:Tlx results in "sausage"
- Anything else: Template returns the contents of
|def=
, or of |yes=
in absence of the former; otherwise, returns "yes".
- Plantilla:Tlx results in "cup of tea"
- Plantilla:Tlx results in "bacon"
- Plantilla:Tlx results in "cup of tea"
For the named parameters, use of a blank value is not the same as omitting the parameter. A blank named parameter tells the template that the customized return value is blank. For example:
- Plantilla:Tlx results in "yes"
- Plantilla:Tlx results in "" Plantilla:Var
Logical distinctions
Overview of Plantilla:Tlx logical values and their associated texts | ||||||
---|---|---|---|---|---|---|
Input parameter 1 (Plantilla:Code) |
In code | Logical return value | Default return text |
Return text when set: Plantilla:Code Plantilla:Code Plantilla:Code Plantilla:Code Plantilla:Code |
Note | |
yes, y, true, 1* | Plantilla:Code | Plantilla:Nowrap | "yes" | "Pos" | * Case-insensitive (Y=y) | |
Plantilla:Nowrap | Plantilla:Nowrap | Plantilla:Code | "yes" | "Def" | "Pos" when Plantilla:Nowrap | |
no, n, false, 0* | Plantilla:Code | Plantilla:Code | "" Plantilla:Var | "Neg" | * Case-insensitive (N=n) | |
Plantilla:Var | Plantilla:Code | Plantilla:Code | "" Plantilla:Var | "Blank" | "Neg" when Plantilla:Nowrap | |
1=Plantilla:Var | Plantilla:Code | Plantilla:Code | "" Plantilla:Var | "Blank" | "Neg" when Plantilla:Nowrap | |
¬ | Plantilla:Code | Plantilla:Code | "" Plantilla:Var | "Undefined" | ||
Plantilla:Var | Plantilla:Code | Plantilla:Code | "" Plantilla:Var | "Undefined" |
Comparison with related templates | |||
---|---|---|---|
Input parameter 1 (Plantilla:Code) | Plantilla:Tl | Plantilla:Tl | Plantilla:Tl |
yes, y, true, 1* | "yes" | "yes" | "yes" |
Plantilla:Nowrap | "yes" | "yes" | "no" |
no, n, false, 0* | "" Plantilla:Var | "no" | "no" |
Plantilla:Var | "" Plantilla:Var | "yes" | "no" |
1=Plantilla:Var | "" Plantilla:Var | "yes" | "no" |
¬ | "" Plantilla:Var | "yes" | "no" |
Plantilla:Var | "" Plantilla:Var | "yes" | "no" |
Full parameter list
Unnamed parameter 1= the input value to be evaluated. The other parameters (all named, all optional), are the return values for their respective logical outcome. When set, each one overrules their default return value.
{{yesno | | yes = | no = | blank= | ¬ = | def = }}
See also
- Module:yesno
- Plantilla:Tlx – slower than Yesno, but can properly handle ref tags inside the parameters
- Plantilla:Tlx – variant of Yesno that defaults to "yes" if value is not explicitly negative
- Plantilla:Tlx – variant of Yesno that defaults to "no" if value is not explicitly positive
TemplateData
This template normalises an input to be a yes or nil output.
Parámetro | Descripción | Tipo | Estado | |
---|---|---|---|---|
Input value | 1 | The value to be evaluated | Cadena | obligatorio |
Output on yes | yes | Specifies the output of the template when the input value is a case-insensitive forms of 'Yes', 'Y', 'True' or '1' | Cadena | opcional |
Output on no | no | Specifies the output of the template when the input value is a case-insensitive forms of 'No', 'N', 'False, or '0' | Cadena | opcional |
Output on blank input | blank | Specifies the output of the template when the input value is defined but is either empty or contains nothing but whitespace character(s) | Cadena | opcional |
Output on ¬ | ¬ | Specifies the output of the template when the input value is either '¬' or entirely missing (undefined) | Cadena | opcional |
Definite output | def | Specifies the output of the template when the input value is defined but not a form of 'yes', 'no', '1', '0', '¬' or blank | Cadena | opcional |
The above documentation is transcluded from Template:Yesno/doc.
[[Special:PrefixIndex/Plantilla:Plantilla:Documentation/template page/|Subpages of this template]]. |