Help:Parser functions in templates

From FORwiki

Jump to: navigation, search

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 definedTRUEFALSE
defined but null/emptyFALSEFALSE
defined and NOT null/emptyTRUETRUE

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

Personal tools