Help:Parser functions in templates
Jump to navigation
Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
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
- {{#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.}}
- {{{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
- {{#if: | 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.}}
- 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.