Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Help:Template
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Handling parameters=== In template code, the value of a parameter is represented by items enclosed between {{em|triple}} braces, which is a ''parameter reference''. * The code <code><nowiki>{{{xxx}}}</nowiki></code> expands to the value of the parameter named "xxx". * The codes <code><nowiki>{{{1}}}</nowiki></code>, <code><nowiki>{{{2}}}</nowiki></code>, and so on are expanded to the first, second, and so on unnamed parameters. (Note that an unnamed parameter can alternatively be specified in a template call as an equivalent named parameter named "1", "2", etc.). If a parameter is not specified in the template call, then the parameter reference is not replaced with anything -- it is expanded literally; this means that if the template call does not specify the parameter "xxx", the wikitext <code><nowiki>{{{xxx}}}</nowiki></code> inside the template expands to literally ''<nowiki>{{{xxx}}}</nowiki>'' (not the null string you may have expected). You can get a more useful behavior by specifying a default value in the parameter reference. Do this with the ''pipe syntax'': <code><nowiki>{{{xxx|dflt}}}</nowiki></code> specifies the default value <code>dflt</code> for the named parameter "xxx", and <code><nowiki>{{{1|dflt}}}</nowiki></code> specifies the default value <code>dflt</code> for the first unnamed parameter. Most often, one specifies a null default value, such as <code><nowiki>{{{1|}}}</nowiki></code> or <code><nowiki>{{{xxx|}}}</nowiki></code>. You can use default parameter values to effect a parameter alias: For example, if parameters "text" and "message" are names for the same parameter, which can also be specified as the only unnamed parameter, then refer to the parameter with <code><nowiki>{{{message|{{{text|{{{1|}}}}}}}}}</nowiki></code>. If the template call specifies more than one of those parameters, "message" will have priority, followed by "text", and finally by the first unnamed parameter. So if a template call specifies parameters <code>|message=A|text=B|C</code>, the above wikitext expands to <code>A</code>. Because of the multiple meanings of double-brace and triple-brace syntax in wikitext, expressions can sometimes be ambiguous. It may be helpful or necessary to include spaces to resolve such ambiguity. For example, <code><nowiki>{{ {{{xxx}}} }}</nowiki></code> or <code><nowiki>{{{ {{xxx}} }}}</nowiki></code>, rather than typing five consecutive braces, may be more human-readable. But watch out for unwanted whitespace appearing in the template expansion. Parameter references do not get expanded when they are wrapped in {{xtag|nowiki}} tags. ====Example==== The parameter usage example above refers to the {{tl|payoff matrix}} template. Here is the code in the template that implements those parameters: <syntaxhighlight lang="wikitext"> {| id="Payoff matrix" style="background:white; float: {{{Float|right}}}; clear:right; text-align:center;" align={{{Float|right}}} cellspacing=0 cellpadding=8 width={{{Width|225}}} |- |style="width:33%; "| |style="width:33%; border-bottom: solid black 1px;"| {{{2L|Left}}} |style="width:33%; border-bottom: solid black 1px;"| {{{2R|Right}}} |- |style="border-right: solid black 1px; text-align: right; "| {{{1U|Up}}} |style="border-right: solid black 1px; border-bottom: solid black 1px; background:{{{ULc|white}}}; font-size:120%; "| {{{UL|0, 0}}} |style="border-right: solid black 1px; border-bottom: solid black 1px; background:{{{URc|white}}}; font-size:120%; "| {{{UR|0, 0}}} |- |style="border-right: solid black 1px; text-align: right; "| {{{1D|Down}}} |style="border-right: solid black 1px; border-bottom: solid black 1px; background:{{{DLc|white}}}; font-size:120%; "| {{{DL|0, 0}}} |style="border-right: solid black 1px; border-bottom: solid black 1px; background:{{{DRc|white}}}; font-size:120%; "| {{{DR|0, 0}}} |- |style="font-size: 90%;" colspan=3 |''{{{Name|{{PAGENAME}}}}}'' |}</syntaxhighlight> The entity <syntaxhighlight lang="wikitext" inline>{{{2L|Left}}}</syntaxhighlight> instructs the template to use the value of the named parameter <code>2L</code> or the text <code>Left</code> if the parameter is not specified in the call. ====Special case: parameters within an XML-style opening tag==== Parameter references aren't expanded inside [[XML]]-style opening tags. Thus, the following will not work within a template: *{{!mxt|<nowiki><ref name={{{param}}}> Smith, Adam (1776)...</ref></nowiki>}} because the parameter is not expanded. Instead, you can use the <code><nowiki>{{#tag:}}</nowiki></code> [[WP:PF|parser function]], which is—for example—used in {{tlx|sfn}} to generate the {{tag|ref}} element; see also {{section link|Help:Magic words|Formatting}}. Therefore, the following example will work: *{{mxt|<nowiki>{{#tag:ref | Smith, Adam (1776)... | name={{{param}}} }}</nowiki>}} ====Caution: overextending URLs==== If a parameter's value is (or ends with) a [[URL]], check whether it is displayed in Wikipedia with the link overextending by one or more characters after the URL so that clicking the link causes an error or failure. This could happen because the source code does not have a space after the URL or it contains or generates a space that is discarded in the processing. Ensure that in the template expansion a soft space ({{em|not}} a [[Non-breaking space|hard or non-breaking space]]) follows the URL, regardless of whether you or a user supplied the URL or whether it was generated by automated processing. The {{tlx|spaces}} template may be useful.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)