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.
- 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.
- 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.