Help:Templates
What is a template?[edit source]
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, later changes to a template will automatically occur on every page where the template is used. Templates help present information in a standard manner across multiple pages. The navigation box at the bottom of this page is an example of a template.
Templates on this wiki can be found at Category:Templates.
For specific infoboxes for Ages, people, etc, see Category:Infobox templates
How to use templates[edit source]
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 appearance 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[edit source]
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 include 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>
Documenting templates[edit source]
If your template has multiple parameters or is complicated to use, you are encouraged to include documentation on how to use it. It is also good practice to include documentation describing when to use your template, regardless of its complexity. To add documentation to a template, add the following to the bottom of the template page:
... template code ...<noinclude> {{documentation}} </noinclude>
This will add the documentation template to the page, which transcludes any material found at
Template:Template name/doc
After you save your template, you can click on the "create" link in the transcluded documentation header to go straight to the /doc page for your template.
Formatting documentation[edit source]
There are no strict formatting guidelines for template documentation, just try to outline everything that the template does and the available parameters. However, the suggested headings for template page are given below. You can also use the "Manage TemplateData" button above the editor when creating your documentation to expedite the process of documenting the template's parameters.
<nowiki> == Description == This template is designed to produce... == Usage == <!-- example wrapped in pre tags --> === Parameters === All parameters are required unless specified. ;parameter1 :This parameter determines... ;parameter2 :Optional. This parameter should be set if... === Example === <!-- pre wrapped example template usage --> <!-- example template usage -->
Content in this section is based on the help documents for Wikipedia and the Guild Wars 2 Wiki. In accordance with the Guild Wars 2 Wiki's licensing terms, the material on this page is licensed under the GNU Free Documentation License (GFDL) 1.2.