Acciones

Plantilla

Diferencia entre revisiones de «If either/doc»

De La Venciclopedia

m (Texto reemplazado: «[[Category:» por «[[Categoría:»)
mSin resumen de edición
 
(No se muestran 2 ediciones intermedias del mismo usuario)
Línea 1: Línea 1:
{{Documentation subpage}} __NOTOC__ __NOEDITSECTION__
{{Subpagina de documentacion}} __NOTOC__ __NOEDITSECTION__
<!----PLEASE ADD CATEGORIES WHERE INDICATED AT THE BOTTOM OF THIS PAGE---->
<!----PLEASE ADD CATEGORIES WHERE INDICATED AT THE BOTTOM OF THIS PAGE---->
: <pre>{{if either ({{!}}'''a''') ({{!}}'''b''') ({{!}}''first result'') ({{!}}''second result'')}}</pre>
: <pre>{{if either ({{!}}'''a''') ({{!}}'''b''') ({{!}}''first result'') ({{!}}''second result'')}}</pre>
Línea 36: Línea 36:
<includeonly>{{Sandbox other||
<includeonly>{{Sandbox other||
<!----CATEGORIES BELOW THIS LINE, PLEASE:---->
<!----CATEGORIES BELOW THIS LINE, PLEASE:---->
[[Categoría:If-then-else templates]]
[[Categoría:Venciclopedia:Plantillas If-then-else|{{PAGENAME}}]]
}}</includeonly>
}}</includeonly>

Revisión actual - 06:45 1 oct 2020

{{if either ({{!}}'''a''') ({{!}}'''b''') ({{!}}''first result'') ({{!}}''second result'')}}
 "If either (a or) (b) is true, (return first result,) (else return second result)."

This helper template is designed to be used in other templates. It can help editors create template code that or self documenting. The major advantage of using this template over using the construct {{#if:{{{1|}}}{{{2|}}} |…}} is that if the first parameter is not empty then the second parameter is not evaluated.

The "or" in the "a or b" above is inclusive: if both a and b are true, the template will return the first result.

This template can also be used to replace the construct {{#if:a |true |{{#if:b |true |false}}}} (i.e. "if a, then true; else if b, then true; else false").

Examples

Code Result
{{if either |a |b |true |false}} true
{{if either |a | |true |false}} true
{{if either | |b |true |false}} true
{{if either | | |true |false}} false

See also