<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://huckjones.strawberryforum.org/w/index.php?action=history&amp;feed=atom&amp;title=Help%3AParser_functions_in_templates</id>
	<title>Help:Parser functions in templates - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://huckjones.strawberryforum.org/w/index.php?action=history&amp;feed=atom&amp;title=Help%3AParser_functions_in_templates"/>
	<link rel="alternate" type="text/html" href="https://huckjones.strawberryforum.org/w/index.php?title=Help:Parser_functions_in_templates&amp;action=history"/>
	<updated>2026-04-04T09:27:48Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://huckjones.strawberryforum.org/w/index.php?title=Help:Parser_functions_in_templates&amp;diff=375&amp;oldid=prev</id>
		<title>Huck: 1 revision</title>
		<link rel="alternate" type="text/html" href="https://huckjones.strawberryforum.org/w/index.php?title=Help:Parser_functions_in_templates&amp;diff=375&amp;oldid=prev"/>
		<updated>2011-07-21T12:21:19Z</updated>

		<summary type="html">&lt;p&gt;1 revision&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;When applying [[Help:Extension:ParserFunctions|ParserFunctions]] to [[Help:Template|template]] parameters, a pipe symbol (&amp;quot;|&amp;quot;) 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.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;tt&amp;gt;&amp;lt;nowiki&amp;gt;{{{1}}}&amp;lt;/nowiki&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:;Sample A: &amp;lt;tt&amp;gt;&amp;lt;nowiki&amp;gt;{{#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.}}&amp;lt;/nowiki&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:;Result: &amp;lt;tt&amp;gt;{{#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.}}&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;tt&amp;gt;&amp;lt;nowiki&amp;gt;{{{1|}}}&amp;lt;/nowiki&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:;Sample B: &amp;lt;tt&amp;gt;&amp;lt;nowiki&amp;gt;{{#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.}}&amp;lt;/nowiki&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:;Result: &amp;lt;tt&amp;gt;{{#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.}}&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Comparison&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Example of usage in a template&amp;lt;br /&amp;gt;anonymous .. 1&amp;lt;br /&amp;gt;param&lt;br /&gt;
! Condition of parameter&lt;br /&gt;
! Sample A:&amp;lt;br /&amp;gt;&amp;lt;nowiki&amp;gt;{{#if: {{{1}}} |&amp;lt;/nowiki&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;nowiki&amp;gt;{{#if: {{{param}}} |&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
! Sample B:&amp;lt;br /&amp;gt;&amp;lt;nowiki&amp;gt;{{#if: {{{1|}}} |&amp;lt;/nowiki&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;nowiki&amp;gt;{{#if: {{{param|}}} |&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{template}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{template}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;||not defined:&amp;lt;br /&amp;gt;parameter not used,&amp;lt;br /&amp;gt;important for named parameters||&amp;#039;&amp;#039;&amp;#039;TRUE&amp;#039;&amp;#039;&amp;#039;||&amp;#039;&amp;#039;FALSE&amp;#039;&amp;#039;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{template|}} .. {{template|1=}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{template|param=}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;||defined, but null/empty||&amp;#039;&amp;#039;FALSE&amp;#039;&amp;#039;||&amp;#039;&amp;#039;FALSE&amp;#039;&amp;#039;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{template|value}} .. {{template|1=value}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{template|param=value}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;||defined&amp;lt;br /&amp;gt;and&amp;lt;br /&amp;gt;NOT null neither empty||&amp;#039;&amp;#039;&amp;#039;TRUE&amp;#039;&amp;#039;&amp;#039;||&amp;#039;&amp;#039;&amp;#039;TRUE&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The second usage (&amp;lt;tt&amp;gt;&amp;lt;nowiki&amp;gt;{{{1|}}}&amp;lt;/nowiki&amp;gt;&amp;lt;/tt&amp;gt;, sample B) with present empty default is often the desired way to handle situations where a parameter exists, but is comprised only of empty space.&lt;br /&gt;
&lt;br /&gt;
One way to test whether a parameter was specified in a template call is thus:&lt;br /&gt;
&amp;lt;tt&amp;gt;&amp;lt;nowiki&amp;gt;{{#ifeq:{{{v|}}}|{{{v|-}}}| v was specified (and may be empty) | v was not specified }}&amp;lt;/nowiki&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In rare cases, a template behaves differently when a parameter is unspecified compared to when it is specified but empty. When this template is used by a wrapper template (which uses the same set of named parameters), one way to ensure undefined parameters remain undefined is as follows (the technique also works with numbered parameters):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- wrapper template code --&amp;gt;&lt;br /&gt;
{{wrapped_template|&lt;br /&gt;
normal_parameter={{{normal_parameter|}}}|&lt;br /&gt;
sensitive_parameter{{#if:{{{sensitive_parameter|}}}||NULL}}={{{sensitive_parameter}}}|&lt;br /&gt;
...&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the &amp;lt;tt&amp;gt;wrapped_template&amp;lt;/tt&amp;gt; receives a specified but empty &amp;lt;tt&amp;gt;normal_parameter&amp;lt;/tt&amp;gt; in two cases: when &amp;lt;tt&amp;gt;normal_parameter&amp;lt;/tt&amp;gt; is specified and empty, and when &amp;lt;tt&amp;gt;normal_parameter&amp;lt;/tt&amp;gt; is unspecified (because the default empty value is then specified by the wrapper template).&lt;br /&gt;
&lt;br /&gt;
By contrast, the &amp;lt;tt&amp;gt;wrapped_template&amp;lt;/tt&amp;gt; receives a specified &amp;lt;tt&amp;gt;sensitive_parameter&amp;lt;/tt&amp;gt; &amp;#039;&amp;#039;only&amp;#039;&amp;#039; when it is indeed specified, because the &amp;lt;tt&amp;gt;#if&amp;lt;/tt&amp;gt; changes the &amp;lt;tt&amp;gt;wrapped_template&amp;lt;/tt&amp;gt; parameter name to « &amp;lt;tt&amp;gt;sensitive_parameterNULL&amp;lt;/tt&amp;gt; » when &amp;lt;tt&amp;gt;sensitive_parameter&amp;lt;/tt&amp;gt; is undefined. Note also that &amp;lt;tt&amp;gt;wrapped_template&amp;lt;/tt&amp;gt; receives a specified and empty &amp;lt;tt&amp;gt;sensitive_parameter&amp;lt;/tt&amp;gt; &amp;#039;&amp;#039;only&amp;#039;&amp;#039; when the wrapper template receives a specified and empty &amp;lt;tt&amp;gt;sensitive_parameter&amp;lt;/tt&amp;gt;. Of course, one must make sure the suffixed &amp;lt;tt&amp;gt;wrapped_template&amp;lt;/tt&amp;gt; parameter name is meaningless to the &amp;lt;tt&amp;gt;wrapped_template&amp;lt;/tt&amp;gt; for this to work properly.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[[Help:Extension:ParserFunctions]]&lt;br /&gt;
*[[Help:Template]]&lt;br /&gt;
*[[Extension:Loops#.23forargs_.28Experimental.29|Extension:Loops#forargs]]&lt;br /&gt;
&lt;br /&gt;
{{Languages}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Help|Parser functions in templates]]&lt;/div&gt;</summary>
		<author><name>Huck</name></author>
	</entry>
</feed>