Help:Template


Description

A template is a wiki page created to be included in other pages. Templates usually contain repetitive material that might need to show up on any number of articles or pages. They are commonly used for boilerplate messages, standard warnings or notices, infoboxes, navigational boxes, and similar purposes.


Usage

Existing templates can be used by adding them with {{Template name}}. For instance {{i18n}} which is the language selection template at the top of this page.

If you want to place a link to a template this works just like other wiki links. Remember to include "Template:". Using the language selection template as example again this would make [[Template:i18n]] -> Template:i18n.


Template categories

Our wiki keeps categories short and simple so we only use a few ones:

Template Category Usage
General Template General templates for this wiki.
Content Template Templates used for pages about content that's already in game.
Development Template Templates used for development-relevant pages.
Translation Template Templates with translations.
Template documentation Documentation about how a certain template works.

See also:


Creating a template

While creating a template itself works similar as creating new pages for the wiki (see Help:Editing) there are a few important points different.

A template is built like this:

Template code goes here

<noinclude>
{{:Template:{{PAGENAME}}/doc}}     <!-- this is to include documentation in this page, without transcluding it in the page where template is used -->
[[Category:General Template]]     <!-- this is to categorize the template. It will not be transcluded in the page where template is used -->
</noinclude>


"Template code goes here" is where you create the template itself. Inside the <noinclude></noinclude> tags you have to place the documentation (see below) and the category for the template.


If you create a new template please always categorize it the same way as listed above and do not create a new category unless you discussed it with a Wiki Administrator or Bureaucrat.


Note: Remember to always put the <noinclude></noinclude> tags around the documentation and category, otherwise all pages using the template will be categorized and include the documentation!


Documentation

Templates need documentations about how to use them. Besides creating the template itself you need to create a new page about its documentation which should be called "Template:template name/doc" by using the Documentation template.

See following example:

{{Documentation
  |Description = Example description.
  |Usage       = Instructions example. Insert this code:
  |Code        = <nowiki>Template name|Arg 1|Arg 2</nowiki>
}}


It will then look like this:


50px-Template-info.png Template documentation [ Edit ]

Description

Example description.

Usage

Instructions example. Insert this code:

{{Template name|Arg 1|Arg 2}}


Translating templates

Most templates are translatable within the original template, meaning you can put translations in the source of them instead of creating a new translated template page. "#switch: {{NAMESPACE}}" allows to create a switch. Depending on which translation page you are at, the variable {{NAMESPACE}} will display the corresponding content. The source for example looks like this:

{{switch: {{NAMESPACE}} | De = German translation goes here | Es = Spanish translation goes here | Fr = French translation goes here | Zh = Traditional Chinese translation goes here | #default = Original English text }}

So for example when you are at the German (De) translation page using a template with this source, it will show "German translation goes here". On the Spanish (Es) translation page it will show the Spanish translation and so on. You might want to check other templates to understand better. See Category Translation Template. Please do only list your language when you really translated the template, otherwise it won't show the default English but an empty template.


However, not every template is translatable in this fashion. Those need new translated templates, just like translation pages. Please name them like this:

"Template:.Fr:Template name", for usage it's "{{.Fr:Template name}}".


Every template which is a translated one or includes a translation needs to be categorized with [[Category:Translation Template]] after the first category (<nowiki>[[General Template]], [[Content Template]], see Template Categories). This way Translators have it easier to look for templates that were already translated.

Wikipedia templates

Although some templates on Wikipedia sound interesting, most of them are not suitable for TMW wiki as Lua programming language is not available here. Also, Wikipedia templates invoke modules which are pages storing some Lua source code.