<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.tfcmud.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Help%3AAdvanced_templates</id>
	<title>Help:Advanced templates - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.tfcmud.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Help%3AAdvanced_templates"/>
	<link rel="alternate" type="text/html" href="https://www.tfcmud.com/wiki/index.php?title=Help:Advanced_templates&amp;action=history"/>
	<updated>2026-06-14T15:32:30Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.36.1</generator>
	<entry>
		<id>https://www.tfcmud.com/wiki/index.php?title=Help:Advanced_templates&amp;diff=222&amp;oldid=prev</id>
		<title>Tynian: 1 revision: Import helps</title>
		<link rel="alternate" type="text/html" href="https://www.tfcmud.com/wiki/index.php?title=Help:Advanced_templates&amp;diff=222&amp;oldid=prev"/>
		<updated>2011-01-10T23:24:21Z</updated>

		<summary type="html">&lt;p&gt;1 revision: Import helps&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{H:h}}[[Category:Editor handbook]]&lt;br /&gt;
&lt;br /&gt;
This page covers '''advanced template techniques''', in particular the use of variable template names and parameter names in templates. Readers should be thoroughly familiar with the standard template techniques found in [[Help:Template]]. Some techniques described below may be outdated or of limited use; for example, [[mw:Help:Extension:ParserFunctions|ParserFunctions]] may be more convenient than some of the branching techniques discussed. &lt;br /&gt;
&lt;br /&gt;
In general, these techniques rely on the recursive (inside-out) processing of templates. When a template is [[Help:Expansion|expanded]] (processed), it translates template code into string values. These are often sent directly to the web browser for display, but they can be treated as code themselves.  By enclosing the text strings in double-curly-brackets ( {{}} ), for instance, they can be reprocessed as template names or variable names, producing different results as the string values are changed.&lt;br /&gt;
&lt;br /&gt;
'''Notes:''' &lt;br /&gt;
*This document refers to features currently only available in the Mediawiki software starting with version 1.6 and later.&lt;br /&gt;
*The term &amp;quot;variable&amp;quot; has two uses in this document:&lt;br /&gt;
**As noun it means [[mw:Help:Magic_words#Variables|a type of magic word]], which is a system-based variable that can be accessed in the same manner as templates (thus &amp;lt;nowiki&amp;gt;{{NAMESPACE}}&amp;lt;/nowiki&amp;gt; will return the name of the current namespace, depending on the page).&lt;br /&gt;
**As adjective or adverb, it is used in the general sense, to indicate that something may vary with context (thus a &amp;quot;variable template name&amp;quot; means that the name of the template being called can change according to parameters or variables).&lt;br /&gt;
*Using &amp;quot;subst:&amp;quot; with manual recursion gives a stepwise replacement, useful for analyzing and explaining the working of templates calling other templates. For instance, compare &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{{{tctc}} }}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; (discussed below) with &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{{{subst:tctc}} }}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; on a sandbox page.  Though both produce the same ''visible'' result, the first will remain as the full code &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{{{tctc}} }}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;, while the second will replace the inner template &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{tctc}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; with its value, leaving the code &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{tc }}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. See, e.g., [[Template talk:Lop]].&lt;br /&gt;
&lt;br /&gt;
== Variable templates ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section begin=vartemp /&amp;gt;In some cases, it may be useful for a template to call different templates depending on a variable or a passed parameter. This allows a type of [[w:en:Conditional_branching#Choice|branching]] that can be simpler than with [[mw:Help:Extension:ParserFunctions|ParserFunctions]], though they are generally less versatile.&amp;lt;section end=vartemp /&amp;gt;&amp;lt;!--section tags for demo in [[Help:Template#Labeled section transclusion]]--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Examples:'''&lt;br /&gt;
&amp;lt;!-- experimenting with different formats&lt;br /&gt;
{|  class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width:75%;border:none&amp;quot;&lt;br /&gt;
|+Using a variable to choose a template - &amp;lt;nowiki&amp;gt;{{ {{NAMESPACE}} }}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!This...&lt;br /&gt;
!Produces this&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;nowiki&amp;gt;{{NAMESPACE}}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|{{NAMESPACE}}&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;nowiki&amp;gt;{{ {{NAMESPACE}} }}&amp;lt;/nowiki&amp;gt; is equivalent to &amp;lt;nowiki&amp;gt;{{&amp;lt;/nowiki&amp;gt; {{NAMESPACE}} &amp;lt;nowiki&amp;gt;}}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|{{ {{NAMESPACE}} }}&lt;br /&gt;
|} --&amp;gt;&lt;br /&gt;
;''Using a variable to choose a template'' - &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{ {{NAMESPACE}} }}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;:The [[Help:Magic_word|magic word]] &amp;lt;nowiki&amp;gt;{{NAMESPACE}}&amp;lt;/nowiki&amp;gt; returns the current namespace, like so: &amp;lt;nowiki&amp;gt;{{NAMESPACE}}&amp;lt;/nowiki&amp;gt; = ''{{NAMESPACE}}''. The outer brackets then process this result as a template in its own right - in this case [[Template:Help]] - which produces ''{{ {{NAMESPACE}} }}''. &lt;br /&gt;
;''Using a template to choose a template'' - &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{{{tctc}} }}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;:the template {{tl|Tctc}} contains the text &amp;quot;tc&amp;quot;. This text is processed by the outer brackets as [[Template:tc]] which contains the word &amp;quot;{{{{tctc}} }}&amp;quot;.  &lt;br /&gt;
&lt;br /&gt;
The extra spaces in the above examples are needed: without them, the pair of inner three braces is taken as those for a parameter. On the page itself it just shows as plain text: {{{{NAMESPACE}}}}.&lt;br /&gt;
&lt;br /&gt;
;''Using a parameter to choose a template'' - &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{{{{2}}}x|{{{1}}}}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;:The second parameter passed becomes part of the template name to which the first parameter is passed. In this case &amp;lt;code&amp;gt;{{tlx|2x|{{{1}}}}}&amp;lt;/code&amp;gt; would produce &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{{1}}}{{{1}}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;{{tlx|3x|{{{1}}}}}&amp;lt;/code&amp;gt; would produce &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{{1}}}{{{1}}}{{{1}}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;, and etc. [[Template:Histogram]] uses this technique repeatedly in {{tlx|histogram|X|4|7|3|2|9}} to produce the following 5 line histogram:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;{{hist5|X|4|7|3|2|9}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using [[parser functions]] and templates, including those which process strings (see [[Help:String functions]] and [[:Category:String templates]]), a template name can also depend in a more complicated way on parameters and/or variables.&lt;br /&gt;
&lt;br /&gt;
== Templates passed as parameters ==&lt;br /&gt;
&lt;br /&gt;
Templates can be passed as parameters to other templates.  This can mean either that the template is evaluated and the result is passed as a parameter or that the template name is passed and evaluated as part of the other template.&lt;br /&gt;
&lt;br /&gt;
;''Passing a template result'' - &amp;lt;nowiki&amp;gt;{{3x|{{tc}}}}&amp;lt;/nowiki&amp;gt;:[[Template:3x]] contains &amp;lt;nowiki&amp;gt;{{{1}}}{{{1}}}{{{1}}}&amp;lt;/nowiki&amp;gt;. &amp;lt;nowiki&amp;gt;{{3x|{{tc}}}}&amp;lt;/nowiki&amp;gt; first evaluates {{tl|tc}} (which yields the word ''in''), and passes that to template {{tl|3x}}, to give {{3x|{{tc}}}}&lt;br /&gt;
;''Passing a template result recursively'' - &amp;lt;nowiki&amp;gt;{{3x|{{5x|{{tc}}}}}}&amp;lt;/nowiki&amp;gt;:Just as above except {{tl|tc}} (''in'') is first passed to {{tl|5x}} and the result of that is passed to {{tl|3x}}, to give {{3x|{{5x|{{tc}}}}}}.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- hiding this temporarily while I sort it out - very confusing&lt;br /&gt;
Thus, it is also possible to use a data array as a parameter of a template, e.g.,:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;{{&amp;lt;/nowiki&amp;gt;hist5a|x|t data}} using &lt;br /&gt;
&lt;br /&gt;
{{timcnl|hist5a}} and &lt;br /&gt;
&lt;br /&gt;
{{timc|t data}} gives:&lt;br /&gt;
&lt;br /&gt;
{{hist5a|x|t data}}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
;''Passing a template name'' - &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{tt|t|V}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;:'''[[Template:tt]]''' - &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{{{{1}}}|a{{{2}}}b{{{2}}}c{{{2}}}d}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; - takes the value '''V''' (passed as the second parameter) and produces ''aVbVcVd''. This value is then passed to '''[[template:t]]''' (which was passed by name as the first parameter), producing &amp;quot;{{tt|t|V}}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Variable parameter name ==&lt;br /&gt;
&lt;br /&gt;
A parameter name in a template can be the value of another parameter.  This is useful if you want the behavior of a template to change based on the information that is provided to it.&lt;br /&gt;
&lt;br /&gt;
'''''Choosing parameters contextually -''''' &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{t pnd|parameter name}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
[[Template:t p]] contains &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{{capital}}} is the capital of {{{country}}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;, with two parameters - &amp;quot;capital&amp;quot; and &amp;quot;country&amp;quot;.  {{timc|t pnd}} can be used to select ''which'' parameter is used in a particular case. Thus:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!This...&lt;br /&gt;
!Produces this&lt;br /&gt;
|-&lt;br /&gt;
|{{tlx|t pnd|capital}}&lt;br /&gt;
|{{t pnd|capital}}&lt;br /&gt;
|-&lt;br /&gt;
|{{tlx|t pnd|country}}&lt;br /&gt;
|{{t pnd|country}}&lt;br /&gt;
|-&lt;br /&gt;
|{{tlx|t pnd|something else}}&lt;br /&gt;
|{{t pnd|something else}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This applies to integer parameters as well, since integer parameters can be specified using the &amp;quot;#=&amp;quot; notation. Passing the integer value N to {{tl|t pnd}} as its parameter will make it look for the Nth unnamed parameter.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
;''Parameter name from another parameter in the same template'' - &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{ppp|p=foo|foo=bar}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;: using [[Template:ppp]], which contains &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{{{{{p}}}}}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;, the code &amp;lt;code&amp;gt;{{ppp|p=foo|foo=bar}}&amp;lt;/code&amp;gt; will first set the parameter named &amp;quot;foo&amp;quot; to the value &amp;quot;bar&amp;quot;, and then set the parameter named &amp;quot;p&amp;quot; to the value of foo, yielding {{ppp|p=foo|foo=bar}}.  The order in which the parameters appear in the code does not matter, but the technique cannot be applied multiple times&amp;amp;mdash;e.g., using [[Template:tvvv]], which contains &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{{{{{{{{p}}}}}}}}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{tvvv|p=foo|foo=bar|bar=biz}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; gives {{tvvv|p=foo|foo=bar|bar=biz}}.&lt;br /&gt;
&lt;br /&gt;
This is e.g. applied in [[w:Template:Reg polyhedra db]], which contains a 2D array in the form {{{{{1}}}|{{{2}}}|1-1=a11|..|m-n=amn}}. The first parameter is the name of a template that provides a particular selection and presentation of a selected row of the array, e.g. [[w:Template:Reg polyhedron stat table]], the second parameter (which is the first parameter of the latter template) specifies the row. The latter templates references element j of the row concerned by a tag of the form {{{{{{1}}}-j}}}&lt;br /&gt;
&lt;br /&gt;
Whilst the same output could also be produced using {#switch:}, this method is less intensive on the server and may help to stay under page limits; see [[Help:Array]].&lt;br /&gt;
&lt;br /&gt;
==Branching techniques without ParserFunctions==&lt;br /&gt;
The parameter default feature was introduced before  [[mw:Help:Extension:ParserFunctions|Extension:ParserFunctions]]. This led to the development of branching methods through the parameter default mechanism. &lt;br /&gt;
&lt;br /&gt;
;''If-defined branches'' - &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{{test{{{test|}}}|{{{then}}}}}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;:If no value is passed for the parameter test, then &amp;lt;nowiki&amp;gt;{{{test{{{test|}}}|{{{then}}}}}}&amp;lt;/nowiki&amp;gt; resolves to &amp;lt;nowiki&amp;gt;{{{test|{{{then}}}}}}&amp;lt;/nowiki&amp;gt; and returns a blank entry (since test is defined as blank). If the parameter &amp;quot;test&amp;quot; is assigned the value &amp;quot;boo&amp;quot;, however, &amp;lt;nowiki&amp;gt;{{{test{{{test|}}}|{{{then}}}}}}&amp;lt;/nowiki&amp;gt; resolves to &amp;lt;nowiki&amp;gt;{{{testboo|{{{then}}}}}}&amp;lt;/nowiki&amp;gt;, and so long as no parameter &amp;quot;testboo&amp;quot; exists, then this will return the value of the parameter &amp;quot;then&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
See [[Template:Ifwpc]] for comparisons.&lt;br /&gt;
&lt;br /&gt;
There was also an [[Help:Array#Array technique using parameter defaults|array technique using parameter defaults]], with the disadvantage that a template using this technique had to be called with, in addition to the normal parameters, a standard parameter definition not reflecting a choice, but necessary to make the template work.&lt;br /&gt;
&lt;br /&gt;
An even older branching technique dates from before the introduction of the parameter default mechanism. It is based on the fact that if in a template call a parameter is assigned a value more than once, the last one counts. This is used in combination with specifying the value of a parameter in a template call, where the name of that parameter depends on a parameter of an outer template. In a call &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{a|b=c|{{{d}}}=e}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;, template:a uses b=c if b≠{{{d}}} and b=e if b={{{d}}}. See [[Template:T pdc]].&lt;br /&gt;
&lt;br /&gt;
Another old &amp;quot;branching technique&amp;quot; is using a template name depending on the value of a parameter (see above).&lt;br /&gt;
&lt;br /&gt;
== Variable variable names ==&lt;br /&gt;
&lt;br /&gt;
;''Magic word depending on a template'' - &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{t curr}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;: {{timc|t curr}} gives the text ''{{CURRENT{{t day}}}}'' without parameters, since it defaults to &amp;lt;nowiki&amp;gt;{{CURRENTDAY}}&amp;lt;/nowiki&amp;gt;, but {{tlx|t curr|DAYNAME}} gives ''{{t curr|DAYNAME}}'' while {{tlx|t curr|MONTHNAME}} gives ''{{t curr|MONTHNAME}}''.  Any magic word that begins with &amp;quot;CURRENT&amp;quot; can be accessed this way.&lt;br /&gt;
&lt;br /&gt;
;''Parser function parameter depending on a template parameter'' - &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{ns:{{{1}}}}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;:In [[Template:Namespace]], which contains &amp;quot;&amp;lt;code&amp;gt;{{msgnw:namespace}}&amp;lt;/code&amp;gt;&amp;quot;, &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{namespace|4}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; gives &amp;quot;{{namespace|4}}&amp;quot;, because ''Meta'' is the name of namespace 4.&lt;br /&gt;
&lt;br /&gt;
== External examples ==&lt;br /&gt;
*VARIABLE MAGIC WORDS&lt;br /&gt;
**[[Template:H:h]] and [[Template:H:f]] (see edit pages, [[Help:MediaWiki_help_policy#Keeping_project-specific_material_separate|MediaWiki help policy]],  and [http://meta.wikimedia.org/w/index.php?title=Special:Allpages/h&amp;amp;namespace=10 list])&lt;br /&gt;
**[[Template:Nsn]] - namespace number (see also below)&lt;br /&gt;
**[[Template:Gns]] - generic namespace name, useful for linking to the corresponding page on another project&lt;br /&gt;
**[[:de:MediaWiki:Newarticletext]] and [[:de:MediaWiki:Noarticletext]] (see edit pages and [http://de.wikipedia.org/w/index.php?title=Spezial:Allpages/MediaWiki&amp;amp;namespace=10 list])&lt;br /&gt;
**[[w:en:Template:H:f]] - for project-specific content on all help pages of the English Wikipedia (requires a blank template on all pages that do not have this content)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- obsolete items hidden for the time being - need to review&lt;br /&gt;
&lt;br /&gt;
:'''''The following is somewhat obsolete on wikis with the [[ParserFunctions]] extension, which allows easier branching.'''''&lt;br /&gt;
&lt;br /&gt;
This can be combined into the following branching technique:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;{{&amp;lt;/nowiki&amp;gt;tts|''first parameter, with fixed name'' = ''name of template to be called if the parameter names are not equal'' | ''second parameter, with the name depending on parameters and/or variables'' = ''name of the template to be called if the parameter names are equal'' }} with  [[Template:Tts]] containing &amp;lt;nowiki&amp;gt;{{{{{&amp;lt;/nowiki&amp;gt;''name of first parameter'' }}}}} (in this case that name is the empty string).&lt;br /&gt;
&lt;br /&gt;
Thus, while carrying out an action in the case of equality can also be done simply by using a template name equal to the constant (the fixed name above), this technique also allows an action in the case of ''in''equality, without having to cover all alternative values (different from the constant) separately.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
Branching depending on whether a parameter is empty is illustrated with {{Tcw|T pdc}}.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;nowiki&amp;gt;{{t pdc|abc}}&amp;lt;/nowiki&amp;gt; gives {{t pdc|abc}}&lt;br /&gt;
*&amp;lt;nowiki&amp;gt;{{t pdc|}}&amp;lt;/nowiki&amp;gt; gives {{t pdc|}}&lt;br /&gt;
*&amp;lt;nowiki&amp;gt;{{t pdc}}&amp;lt;/nowiki&amp;gt; gives {{t pdc}}&lt;br /&gt;
&lt;br /&gt;
Example with an extra parameter:&lt;br /&gt;
&lt;br /&gt;
Consider {{timc|ine}}, which calls {{timc|call}}: '''I'''f the first parameter is '''N'''ot '''E'''mpty then do the task given by the first parameter with the second, third and fourth parameter as its parameters, else do nothing; if the number of parameters of the task is 0, 1, or 2, ignore the superfluous values.&lt;br /&gt;
&lt;br /&gt;
Using {{timc|Death}}:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;nowiki&amp;gt;{{ine|death|[[November 2]], [[2004]]|[[Amsterdam]]|}}&amp;lt;/nowiki&amp;gt; gives:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;{{ine|death|[[November 2]], [[2004]]|[[Amsterdam]]|}}&amp;quot;.&lt;br /&gt;
*&amp;lt;nowiki&amp;gt;{{ine|death||comment|}}&amp;lt;/nowiki&amp;gt; gives &amp;quot;{{ine|death||comment|}}&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
This can be useful inside another template, to avoid the texts &amp;quot;Date of death:&amp;quot; and &amp;quot;place of death:&amp;quot; for a living person.&lt;br /&gt;
&lt;br /&gt;
Also, without a separate template Death, with just the more general {{timc|p2p1p3}}:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;nowiki&amp;gt;{{ine|p2p1p3|[[November 2]], [[2004]]|Date of death:&amp;amp;nbsp; |, place of death: [[Amsterdam]]}}&amp;lt;/nowiki&amp;gt; gives:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;{{ine|p2p1p3|[[November 2]], [[2004]]|Date of death:&amp;amp;nbsp; |, place of death: [[Amsterdam]]}}&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
This would not be convenient to use in many template tags, but could be used in an infobox in the form&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;nowiki&amp;gt;{{&amp;lt;/nowiki&amp;gt;ine|p2p1p3|{{{1}}}|Date of death:&amp;amp;nbsp; |, place of death: {{{2}}}}}&lt;br /&gt;
&lt;br /&gt;
(Alternatively a separate parameter &amp;quot;dead&amp;quot; with one of the values &amp;quot;dead&amp;quot; and &amp;quot;alive&amp;quot; is used, see, e.g., [[w:en:Template:Infobox President]] with the auxiliary templates [[w:en:Template:Infobox President/dead]] and the empty [[w:en:Template:Infobox President/alive]]. A disadvantage is the extra parameter: it has to be specified that a president is alive, it is not sufficient to leave the date of death empty, or that a president is dead, even if a date of death has been specified. An advantage is that backlinks are available, providing not only a list of dead, but also a list of alive presidents for which the infobox is used.)&lt;br /&gt;
&lt;br /&gt;
Similarly, where a table row dealing with a parameter is removed if the parameter is empty:&lt;br /&gt;
&lt;br /&gt;
[[w:en:Template:If defined call1]] calls [[w:en:Template:Template_call1]] with 1={{{2}}} followed by 1{{{1}}}=void; if {{{1}}} is empty then this overwrites the value of 1, so 1=void, otherwise 1={{{2}}}, giving an empty result or {{{{{2}}}|{{{3}}}}}. {{{3}}} is typically the same as {{{1}}} (at least that is the case in all five cases in [[w:en:Template:Infobox CVG]]). It avoids e.g. the text &amp;quot;Designer:&amp;quot; if the parameter {{{designer}}} is empty.&lt;br /&gt;
&lt;br /&gt;
More generally, using {{timc|If equal g}}:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;nowiki&amp;gt;{{if equal g|2x|3x|{{NAMESPACE}}|Help|a||}}&amp;lt;/nowiki&amp;gt; gives {{if equal g|2x|3x|{{NAMESPACE}}|Help|a||}}&lt;br /&gt;
*&amp;lt;nowiki&amp;gt;{{if equal g|2x|3x|Help|{{NAMESPACE}}|a||}}&amp;lt;/nowiki&amp;gt; gives {{if equal g|2x|3x|Help|{{NAMESPACE}}|a||}}&lt;br /&gt;
*&amp;lt;nowiki&amp;gt;{{if equal g|2x|3x|{{NAMESPACE}}|Template_talk|a||}}&amp;lt;/nowiki&amp;gt; gives {{if equal g|2x|3x|{{NAMESPACE}}|Template_talk|a||}}&lt;br /&gt;
*&amp;lt;nowiki&amp;gt;{{if equal g|2x|3x|Template_talk|{{NAMESPACE}}|a||}}&amp;lt;/nowiki&amp;gt; gives {{if equal g|2x|3x|Template_talk|{{NAMESPACE}}|a||}}&lt;br /&gt;
&lt;br /&gt;
Note that &amp;lt;nowiki&amp;gt;{{&amp;lt;/nowiki&amp;gt;NAMESPACE}} produces underscores for spaces, which are not considered equal by the template:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;nowiki&amp;gt;{{if equal g|2x|3x|Template_talk|Template talk|a||}}&amp;lt;/nowiki&amp;gt; gives {{if equal g|2x|3x|Template_talk|Template talk|a||}}&lt;br /&gt;
*&amp;lt;nowiki&amp;gt;{{if equal g|2x|3x|Template_talk|Template_talk|a||}}&amp;lt;/nowiki&amp;gt; gives {{if equal g|2x|3x|Template_talk|Template_talk|a||}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Producing the value of a parameter whose name depends on the value of another parameter==&lt;br /&gt;
&lt;br /&gt;
The technique can also be used to create control flow structures. An ''ifdef''-function as in {{tim|ifdef}} could look like:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;{{{test{{{test|}}}|{{{then}}}}}}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
If '''test''' is empty, we expand the empty '''test''' parameter, but if it contains data, then after trying to expand a non-existing &lt;br /&gt;
'''test''data'''''-parameter, we get the '''then'''-parameter value instead. Or a literal {&amp;amp;#123;{then}&amp;amp;#125;}, if there's intentionaly&lt;br /&gt;
no default value for '''then''', and '''then''' is undefined - a crude mechanism to catch errors.&lt;br /&gt;
&lt;br /&gt;
Of course, this fails for a, say, '''test''' value ''it'' if '''testit''' is defined. An example with numerical parameters:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;{{{1{{{1|}}}|okay}}}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
For a defined first parameter, we expect to get the text ''okay''. But if the value of the first parameter is, say, 0, and a tenth parameter&lt;br /&gt;
exists, we get its value {&amp;amp;#123;{10}&amp;amp;#125;} instead of ''okay''. &lt;br /&gt;
&lt;br /&gt;
It's slightly different for an ''ifndef''-function as in {{tim|ifndef}}:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;{{{then{{{test|}}}|}}}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
If '''test''' is empty, then we expand the '''then''' parameter. But if '''test''' contains data, then we try to expand a nonexisting '''then''data'''''-parameter,&lt;br /&gt;
finally arriving at its empty default value (= after the second &amp;quot;|&amp;quot; pipe symbol).&lt;br /&gt;
&lt;br /&gt;
Again this fails if the non-existing parameter in fact does exist, e.g., for&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;{{{x{{{1|}}}|}}}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
with a defined value ''y'' for '''x''' we expect to get the empty default for a non-existing '''xy'''. This fails if {&amp;amp;#123;{xy}&amp;amp;#125;} is defined and non-empty.&lt;br /&gt;
&lt;br /&gt;
An if-then-else could be a combination of those two, as in {{timc|ifold}}. &lt;br /&gt;
&lt;br /&gt;
For simple ''ifdef''-cases the best solution is arguably to use it without additional template, e.g. for text relevant only if the third positional parameter is defined use:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;{{{3{{{3|}}}|found third parameter}}}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
For the opposite ''ifndef''-case there's unfortunately no similar direct approach.&lt;br /&gt;
Substitution works for [[Template:ifdef|ifdef]], but not [[Template:ifndef|ifndef]] or [[Template:ifold|ifold]].&lt;br /&gt;
&lt;br /&gt;
A parameter value can also be used as ''part'' of the name of another parameter:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{switch&lt;br /&gt;
  |{{CURRENTDOW}}&lt;br /&gt;
  |case: 1=Mon&lt;br /&gt;
  |case: 2=Tue&lt;br /&gt;
  |case: 3=Wed&lt;br /&gt;
  |case: 4=Thu&lt;br /&gt;
  |case: 5=Fri&lt;br /&gt;
  |case: 6=Sat&lt;br /&gt;
  |case: 0=Sun&lt;br /&gt;
  |default=No date&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using {{timc|switch}} gives {{switch&lt;br /&gt;
  |{{CURRENTDOW}}&lt;br /&gt;
  |case: 1=Mon&lt;br /&gt;
  |case: 2=Tue&lt;br /&gt;
  |case: 3=Wed&lt;br /&gt;
  |case: 4=Thu&lt;br /&gt;
  |case: 5=Fri&lt;br /&gt;
  |case: 6=Sat&lt;br /&gt;
  |case: 0=Sun&lt;br /&gt;
  |default=No date&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Using this technique and an auxiliary template, we can produce a function that checks if two parameter values are the same:&lt;br /&gt;
&lt;br /&gt;
{{timc|equal}}, with {{timc|vv2}}.&lt;br /&gt;
&lt;br /&gt;
It will return 1 if equal, or null (the empty string) if not.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[[mw:Help:Extension:ParserFunctions|ParserFunctions]] (Syntax for &amp;lt;tt&amp;gt;&amp;lt;nowiki&amp;gt;#if:, #expr:&amp;lt;/nowiki&amp;gt;&amp;lt;/tt&amp;gt; etc.)&lt;br /&gt;
*[[Meta talk:Templates for translating language names]]&lt;br /&gt;
*[[Help:Array]]&lt;br /&gt;
&lt;br /&gt;
{{h:f|enname=Advanced templates}}&lt;/div&gt;</summary>
		<author><name>Tynian</name></author>
	</entry>
</feed>