as:
This page needs work, for the following reasons(s): Incorrect information.
A bat is a kind of bug that lives in caves. It has glowing eyes that can shoot lasers!
The value or values passed in to the template are substituted into the corresponding parameters defined in the template’s code. Parameters are specified using three curly brackets. Why does the template contain the string "
{{{Problem|}}}
" and not just "
{{{Problem}}}
"? That’s because MediaWiki has the unfortunate default behavior of literally displaying parameter strings if values aren’t passed in to them. So, if the template contained simply "
{{{Problem}}}
", and the template call looked like "
{{Needs work}}
" (i.e., with no values), the call would get displayed as:
This page needs work, for the following reasons(s): {{{Problem}}}.
The pipe placed at the end tells MediaWiki to display an alternate string if the parameter isn’t set: in this case, nothing. You could also use the pipe to display alternate text: if the parameter tag looked like “
{{{Problem|Unknown}}}
", then a plain call to the "Needs work" template would display this:
This page needs work, for the following reasons(s): Unknown
Templates can also have unnamed parameters; these are defined by their index, i.e. their order in the set of parameters, starting with 1. Let’s take a simple (and rather pointless) example, a template called "Painting" whose relevant section is this:
{{{1|}}} is a painting by {{{2|}}}./
A call that looked like "
{{Painting|Composition with Red, Yellow and Blue|Piet Mondrian}}
" would display the following:
Composition with Red, Yellow and Blue is a painting by Piet Mondrian.
Numbered and named parameters can be combined in the same template, which can be useful in certain situations, though it’s not usually recommended. If a template is passed both named and unnamed values, then the parameters {{{1}}}, {{{2}}} etc. will get the 1st, 2nd and so on values that do not have a name assigned to them — not necessarily the 1st, 2nd etc. values.
There’s one more tag that can be used in templates — . This tag is a little trickier than and , because it affects text outside of the tag itself. If you add one or more tags to a template page (or to a regular page that’s transcluded), then only the text within the tags gets displayed in other pages. All other text — whether or not it’s part of or tags — is ignored.
Uses for templates
There are generally six main usages for templates within MediaWiki: (1) tags to highlight problems within a page, (2) infoboxes, (3) navigation boxes, (4) structural elements, (5) formatting aids and (6) templates used as formatting aids directly by various extensions.
The "Needs work" template was an example of a problem-highlighting tag . Infoboxes are well-known to readers of Wikipedia; they usually appear on the right-hand side of the page, and show important information about the page’s subject. Figure 4.1 shows one example from the English Wikipedia.
Figure 4.1 An infobox from the English-language Wikipedia
Navigation boxes typically have no parameters; on Wikipedia, they’re usually found on either the bottom or the side of the page, and show a large set of links to related pages. You can see an example of it from the English Wikipedia in Figure 4.2.
Figure 4.2 A navigation box from the English-language Wikipedia
Templates can also be used to display standard structural elements of a page; a common example on the English-language Wikipedia is the “Reflist” template, which is basically just a wrapper around the Cite extension’s tag function, providing some additional formatting options.
Templates can be used to do inline formatting of text and images, to simplify work for editors. An example is the "Convert" template on the English Wikipedia, which lets you