Help:Templates

Introduction
What are templates?

Templates, on a Wiki, are pages which contain things to be "included" on to other pages, be it complex functions or a short message, templates can be used for a large number of purposes. This page will help you understand what they are, what they're capable of and how to create your own.

Transclusion: The basics
In computer science, transclusion means "inclusion of part of a document into another" and is used to display templates on other pages.

In the following code, we will transclude the template "Example": What would this display? Whatever the template page "Random" contained (with some exceptions, see below), templates are useful for a lot of things, be it to save time when creating pages, for consistency when styling, or just laziness of the author. For example, users can create customized signatures which could serve as a "template" being stored on a different page (for that, see Help:Signatures).

Substitution
Substitution will write the templates contents to the page, some templates are better left non-substituted, but where possible, they should be. Here's how:

The above example will substitute the "Example" templates contents.

Namespaces
By default, contents of the curly brackets ( ) will fetch data from the Template namespace, you can change this by adding the namespace before the page name, for example:  This will transclude the page User:Example, see Help:Namespaces for a list of namespaces this wiki uses.

Testing your own
Note: you will need to be logged in to edit pages to test. First, go to a sub-page of your user page (see Help:User Pages on how to do this) and insert anything -- it doesn't have to be anything special or contain complex functions, a simple "Hello" would work.

On another user sub-page, write out this: Preview and then submit this, you should now see something like: Hello Hello  Now, there are no noticeable differences between the two, right? Let's check the source again, you should see something like this:

Notice how the last template call turned in to "Hello"? That is substitution.

Where from here
Well, there isn't much to templates, it's more the contents of them such as functions and conditional statements. Here are some links to Meta to further explain:


 * Help:ParserFunctions
 * Transclusion
 * Help:Template
 * Help:Substitution