Help:Templates

This is article is meant to clarify basic template use. This is NOT a tutorial for atually writing templates.

What are templates?
Templates are segments of wiki code that are stored in one central location so that they can be used repeatedly. They are made up of Wiki markup, HTML, and CSS markup just like every other page on Wookieepedia. In fact, templates are no different from any other page except that they are usually stored in the 'Template' namespace.

Template calls
Adding a template call to a page tells the MediaWiki software to substitute the code stored in the template into that page's source code every time the page renders in a browser.

Sytax
A template call consists of the template's name followed by any included parameters, all of which are delimited by a pipe ("|") symbol. The entire template invocation is then surrounded by double curly brackets ("&#123;&#123;&hellip;&#125;&#125;").

Code:
The code above invokes the Quote template.
 * Note that including the template namespace in the template call is optional and that the first letter of the template's title is not case sensitive. works exactly the same.
 * Note that the template looks strange in the example above because it was expecting the user to assign values to its unnamed variables though the use of template call parameters. We will discuss how to do that next...

Variables
Template behavior can be modified somewhat through the use of template call parameters which are used to assign values to variables built into the template. Template variables come in two distinct flavors: named and unnamed.

Unnamed variables
Unnamed variables are tricky because they require the editor to know quite a lot about the internal workings of the template they intend to call. Within the template's code, unnamed variables are referenced using numbers rather than names. Those numbers correspond to their position in the parameter list of the template call. You can assign values to unnamed variables in one of two ways:

OR

Example:
"Hello world!"

- anonymous

Code:
OR

The template calls above assign values to the first and second unnamed variables contained in the quote template.
 * Note that if you use the second method of unnamed variable assignment, the template call behavior is exactly the same as that for named variables.

Named variables
Named variables can only be assigned a value by directly adding the variable's name into the parameter list and explicitly assigning it a value through the use of an equals ("=") symbol, thus creating a standard programming 'name=value' pair.

Code:
The template call above includes a parameter that assigns a color value to the C1 variable of the Jedi Civil War campaign template. Thus, the infobox generated by the template has a black title cell.
 * Note that it does not matter what order you list named parameters in.
 * Note that if we substituted the code, the parameter is ignored and template appears as normal because it contains no unnamed variables:

Thus produces a background color of 'white', not 'black':
 * Note also that if a single variable is assigned a value twice within a template call, the second value assignment (right to left) will superscede the first.

Templates are not wiki tables
A lot of users understandibly confuse template calls with wiki table syntax. It is important to understand that the two constructs are in no way connected.

Wikimedia Meta-Wiki

 * Help:Template
 * Help:Advanced templates
 * Help:Template documentation
 * Help:Variable
 * Help:Magic words
 * Help:Parameter default
 * Help:Namespace
 * Help:Substitution
 * Help:Colon function

Mediawiki

 * Help:Templates