Help:Templates

From Guild Wars Wiki
Jump to navigationJump to search
What is a template?

A template is a page that is meant to automate parts of other pages, for example navigation bars or infoboxes. Including a template is formally called transclusion. The wiki code of the template is not inserted and saved in the page, just a call to the template. Thus, changes to a template will automatically reflect on pages that include that template. Templates help present information in a standard manner across multiple pages. The navigation box at the top of this page is an example of a template.

Templates can be found at Category:Templates.

How to use templates

The minimum syntax required to add a template to a page is:

{{Template name}}

Except for the first letter of the template name, the syntax is case-sensitive.

Parameters

Some templates may require parameters for them to display properly, or to alter the appeareance and functionality for different usages. Parameters act as a placeholder where a specified value can be substituted. Parameters can either be named or numbered starting at 1. For templates that have named parameters, the syntax is:

{{Template name|parameter1=value1|parameter2=value2}}

For templates that have numbered parameters, the parameter name is not necessary.

{{Template name|value1|value2}}

Templates can be written in multiple lines for readability.

{{Template name
| parameter1 = value1
| paremeter2 = value2
}}

Substitution

Templates can be substituted into a page. This is different from transclusion in that the actual wiki code of the template is inserted into the page and saved. Changes to the template will not reflect in pages that have the template substituted. The syntax to substitute a template is:

{{subst:Template name}}

How to create templates

Templates are created like any other page. Generally, a template is created in the Template namespace. Other namespaces can be used, but the namespace must be included in the template call.

{{Namespace:Template name}}

Parameters

The syntax to add a parameter is:

{{{parameter}}}

A parameter can have a default value that will be used when no value is specified.

{{{parameter|default value}}}

<noinclude>

A template may include information that should not be transcluded such as documentation. The parts of the template that is not meant to be included can be wrapped with a <noinclude> tag. It is preferable to not have any whitespace between the end of the wiki code and the <noinclude> tag.

Template wiki code<noinclude>Text that will not be included</noinclude>

For formatting guidelines on templates, see Guild Wars Wiki:Formatting/Templates.