Guild Wars Wiki:Formatting/Templates

From Guild Wars Wiki
Jump to navigationJump to search
Formatting guideline

This page is an accepted formatting guideline on the Guild Wars Wiki.

It has wide acceptance among editors and is considered a standard that all contributors should follow. Before editing this page, it is suggested to gather consensus on the talk page first.

Shortcut:
GWW:TEMPLATES

Templates help separate content from formatting. When applied properly, they can greatly ease the work of editing or creating articles.

Using templates[edit]

The following examples use two fictional template named Template:Foo and Template:Bar. Foo has three named parameters (param1, param2, param3), Bar has two unnamed parameters (1, 2) and two optional named parameters (optional1, optional2).

Note that when using unnamed parameters without equal signs, all whitespaces before and after the value are passed to the template which can generate unexpected output. When using equal signs all whitespaces are trimmed before they are evaluated by the template.

Multiline syntax[edit]

When using complex templates which generates a block or table of information (such as infobox templates) or templates which require a lot of parameters, it is recommended to use multiline syntax. Readability is very much improved when the numerous parameters of a complex template is spaced out over several lines.

{{ Foo
| param1 = Value 1
| param2 = Value 2
| param3 = Value 3
}}

When using unnamed parameters (in template code used with numbers, for example {{{1}}}) within complex templates, you can refer to them by using the number as parameter name:

{{ Bar
| 1 = Value of unnamed parameter 1
| 2 = Value of unnamed parameter 2
| optional1 = Value of optional parameter 1
}}

Inline syntax[edit]

When using templates which generate replacement text and are meant to be used within a block of text, or templates that have only a few parameters, inline syntax is recommended. Templates such as {{Gr}} and {{tl}} are good examples of such templates.

{{Bar|Value of unnamed parameter 1|Value of unnamed parameter 2}}

{{Bar|ValueA|ValueB|optional1 = Value C }}

{{Foo| param1 = Value 1| param2 = Value 2| param3 = Value 3}}

Creating templates[edit]

When creating templates, use the following conventions as guidelines:

  • As parameter names are case-sensitive, specify parameters in lowercase.
  • Create templates in the Template: namespace (unless your template is for personal use only, in which case, save it in your own User: namespace)
  • Categorize templates appropriately (see Category:Templates). Make sure to insert the category tags within <noinclude> tags (see example below).
  • Provide a description and usage guidelines for your template, including explanations for parameters. Examples are encouraged to illustrate usage (this should go into the <noinclude></noinclude> block as well)

The following is a detailed example of how a template page should be formatted:

<!--
your template code
--><noinclude>

== Description ==
<pre>{{ Foo
| bar1 = 
| bar2 =
| bar3 =
}}</pre>
A short description about the template, followed by a general example with all parameters used

=== Parameters ===
<!-- parameter description;
 list also unnamed parameters here with their corresponding number as parameter name.
 For parameters which only accept a limited number of different values, list the possibilities
-->
; bar1
: Description about parameter "bar1"
; bar2
: Optional. Description about parameter "bar2" (default: <code>value</code>)
; bar3
: Optional. Description about parameter "bar3". Possible values:
:* <code>Value 1</code> for doing this
:* <code>Value 2</code> for doing that

== Examples ==
<!-- optional: examples if necessary -->
<pre>{{ Foo
| bar1 = Value
}}</pre>

{{ Foo
| bar1 = Value
}}

== See also ==
<!-- optional: for links to relating articles/categories -->
* [[Guild Wars Wiki:Formatting/Templates|Template formatting guide]]

<!-- categories -->
[[Category:Templates]]
</noinclude>

See also[edit]