Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Numinix MediaWiki Demo
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Help/Templates
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
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!
=== Default values === <!--T:56--> </translate> <translate> <!--T:57--> If you transclude a template that expects parameters, but do not provide their arguments, in this way: </translate> <translate><!--T:58--> <nowiki></nowiki></translate> <translate> <!--T:59--> in the numbered parameters example above you would get the following: </translate> <translate> <!--T:61--> Since no arguments were passed in, the template presents the parameters themselves, instead of their respective values. In these cases, it may be useful to define ''default'' values for the parameters, i.e. values that will be used if no value is passed in. For example, if the template contents are changed to: </translate> <syntaxhighlight lang=moin> <translate nowrap><!--T:62--> '''A little thank you...''' for }. Hugs, }</translate> </syntaxhighlight> <translate> <!--T:63--> then <code><nowiki>}</nowiki></code> defines that if no argument is provided for parameter <code>}</code>, then the value <code>everything</code> will be used. Similarly, <code><nowiki>}</nowiki></code>, defaults parameter <code>}</code> to value <code>Me</code>. Now, transcluding the template again without passing any argument results in the following: </translate> <!-- strictly speaking, this example is false, because the template call was changed to obtain the desired effect - but the effect is the same if the template is defined as described --> <translate> <!--T:146--> </translate> </nowiki></code></tvar> or <tvar name=2><code><nowiki></nowiki></code></tvar>, the <tvar name=5><code>foo</code></tvar> template considers the <tvar name=3><code>bar</code></tvar> parameter to be <tvar name=4><code>""</code></tvar>.</translate> <translate><!--T:233--> This is different from omitting the parameter altogether, which leaves it undefined and triggers the default value mechanism described above.</translate> }} {{note|1=<translate><!--T:342--> If you need to treat an empty string the same way as a missing parameter, you can use a conditional operator through an extension like [[<tvar name=1>Special:MyLanguage/Extension:ParserFunctions</tvar>|ParserFunctions]].</translate> <translate><!--T:343--> For instance, <tvar name=1><code><nowiki>}|}|undefined}}</nowiki></code></tvar> returns undefined if the parameter is either undefined or empty, while <tvar name=2><code><nowiki>}</nowiki></code></tvar> does so only if the parameter is undefined.</translate> }} <translate><!--T:194--> Default values are often used to specify alternate names of parameters.</translate> <translate><!--T:195--> For example, if you have <tvar name=1><code><nowiki>} }}}</nowiki></code></tvar>, the template will first look for a parameter named "<tvar name=2>a</tvar>".</translate> <translate><!--T:196--> If it is not set, it will use the parameter named "<tvar name=1>b</tvar>".</translate> <translate><!--T:197--> If neither "<tvar name=1>a</tvar>" nor "<tvar name=2>b</tvar>" is set, it will output nothing.</translate> <translate>
Summary:
Please note that all contributions to Numinix MediaWiki Demo may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Project:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)