Template
From Retro CDN
A key component of the Mediawiki software is the concept of templates - small sections of wikicode that are used to represent larger sections. The Retro wikis use templates extensively to minimise the amount of typing needed to produce a page. It also allows pages to share code, reducing the amount of wiki maintenance.
Template pages are housed exclusively in the template namespace, and so start must start with the prefix "Template:".
Basic use
If you're familiar with any form of computer programming, a Mediawiki template can be likened to a function call. A template has a name and an optional list of parameters (arguments). When used on a wiki page, templates usually take the form of:
{{test|value1|value2}}
Arguments (in this case, "value1" and "value2") are passed to the template when the page is saved. For all intents and purposes, there is no limit to the amount of arguments that can be passed. Templates are identified by the use of double curly brackets (opening with "{{" and closing with "}}"), with arguments separated with the "|" (pipe) character.
Note: there are some exceptions to this rule - a "#" symbol after the opening curly brackets signals an internal function is being called (e.g. the conditional statement, "{{#if:"). This will be covered in a different help page.
The above example is attempting to call "Template:test" and pass it two arguments; "value1" and "value2".
Here is what Template:test might look like:
Hello {{{1}}}. Learning how to use templates is {{{2}}}.
When the page is saved, Template:test is coped in its entirity and placed where the template exists on the page. {{{1}}} and {{{2}}} will be replaced with the two arguments.
If done correctly,
{{test|Muhammad Ali|fun}}
should produce
Hello Muhammad Ali. Learning how to use templates is fun.
In this example, the arguments were not given names, so are represented by numbers. If we wanted to be a little cleaner, the template might look something like this:
Hello {{{name}}}. Learning how to use templates is {{{adjective}}}.
To get the same result, our call must be changed too:
{{test|name=Muhammad Ali|adjective=fun}}
Templates can get very complicated, however, so it is often wise to use a different format to make it more readible:
{{test | name=Muhammad Ali | adjective=fun }}
While the difference is negligible in a template as small as this, massive templates maintained by dozens of people rely on good formatting, so it's good to get into the habit early on.
Practical examples
Template:Color exists to quickly change the colour of text. This saves editors having to write long-handed HTML code every time they want to change the colour.
e.g.:
{{color|color=blue|background=#FF7777|content=bloogly doogle}}
produces
bloogly doogle
Retro CDN mainly uses templates to mark files - in File:Sonic Adventure title.png, the template {{DCSS}} is used to both categorise the Sonic Adventure title screen as a Dreamcast screenshot, but also to add the message describing the file as such. On Sega Retro, Template:DCSS is used for every Dreamcast screenshot (of which there are hundreds) - if our legal ramblings need to change, we only need to edit one template, as opposed to 100+ individual files.
Templates can also be "nested". DCSS calls Template:Imagetag. Templates can also be passed as arguments.