Difference between revisions of "Help:Parser functions in templates"
Jump to navigation
Jump to search
Rboatright (talk | contribs) m (1 revision(s)) |
|
(No difference)
|
Latest revision as of 01:38, 23 July 2009
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.