Hilfe:Parser functions in templates: Unterschied zwischen den Versionen

Aus Salzwiki
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
 
K (1 Version)
 
(kein Unterschied)

Aktuelle Version vom 29. Juli 2009, 12:49 Uhr

When applying ParserFunctions to template parameters, a pipe symbol ("|") may be used to provide the empty string as default value, in order to indicate how to handle things if a parameter is or is not passed in.

  • {{{1}}}
Sample A
{{#if: {{{1}}} | Parameter 1 is not defined, or is defined and non-null/non-empty. | Parameter 1 is null. It contains only empty string(s) or breaking space(s) etc.}}
Result
Parameter 1 is not defined, or is defined and non-null/non-empty.
  • {{{1|}}}
Sample B
{{#if: {{{1|}}} | Parameter 1 is defined and non-null/non-empty. | Parameter 1 is not defined, or is defined but null. It contains only empty string(s) or breaking space(s) etc.}}
Result
Parameter 1 is not defined, or is defined but null. It contains only empty string(s) or breaking space(s) etc.
Comparison
Condition of parameter 1 Sample A: {{{1}}} Sample B: {{{1|}}}
not defined TRUE FALSE
defined but null/empty FALSE FALSE
defined and NOT null/empty TRUE TRUE

The second usage ({{{1|}}}) is often the desired way to handle situations where a parameter exists, but is comprised only of empty space.

See also