Help:Template

From ArchWiki
Revision as of 07:45, 20 July 2013 by Bwid (Talk | contribs) (+Category: Template)

Jump to: navigation, search

Template:Article summary start Template:Article summary text Template:Article summary end

A template is a piece of predefined wikitext that can be inserted into an article. Templates are primarily used to aid in formatting content.

Visit Category:Template for a listing of all available templates.

Usage

Templates are used by adding the following markup to an article:

{{Template Name}}

Most templates take additional arguments, such as Template:Note:

{{Note|This text should be noted.}}

which produces:

Note: This text should be noted.

Some templates use named parameters, such as Template:Hc:

{{Hc|head=/etc/rc.local|output=exit 0}}

which produces:

/etc/rc.local
exit 0

The general format is:

{{Template Name|param1|param2|...|paramN}}

See each templates' page for specific usage instructions.

Escape template-breaking characters

There are some characters that, if used inside a template, will break its output: most frequently this happens with = (the equal sign) and | (the pipe sign).

The easiest and most effective solutions to this problem are:

  • Using numbered parameters like in:
Note: This method is effective only with = and is very useful with query strings in URLs, e.g. https://www.archlinux.org/?foo=bar
{{Note|1=This method is effective only with = and is very useful with query strings in URLs, e.g. https://www.archlinux.org/?foo=bar}}
  • Replacing the offending characters with their respective HTML entities, like in:
Note: This method supports all kinds of characters, including =, | and }} ( https://www.archlinux.org/?foo=bar )
{{Note|This method supports all kinds of characters, including =, | and }} ( https://www.archlinux.org/?foo=bar )}}
  • Enclosing the offending characters in <nowiki> tags, like in:
Note: This method displays all kinds of characters ( = | }} ), but completely prevents the wiki engine from processing text markup, like links ( https://www.archlinux.org/ ) and other templates ( {{ic|foo}} ).
{{Note|<nowiki>This method displays all kinds of characters ( = | }} ), but completely prevents the wiki engine from processing text markup, like links ( https://www.archlinux.org/ ) and other templates ( {{ic|foo}} ).</nowiki>}}

Creation

Note:
  • Only create relevant templates. If you are attempting to create a very specialized template that will likely only ever be used on a few articles, please do not bother, avoid cluttering up the templates namespace.
  • Only create concise templates. Remember The Arch Way: Keep It Simple, Stupid!

The following template should be used when creating new templates to ensure that the template is a member of Category:Template and to facilitate usage and editing:

<noinclude>{{Template}}

'''A brief description of the template'''

====Usage====

{{ic|<nowiki>{{Template Name|param1|param2|...|paramN}}</nowiki>}}

====Example====

{{Template Name|param1|param2|...|paramN}}</noinclude><includeonly>Template code goes here...</includeonly>

To begin the creation process, simply visit Template:Template Name (substituting Template Name with the desired name of the template), edit, and add the relevant wikitext.

Frequently used templates

Some of the templates most frequently used on the Arch Wiki are listed below. Click on the links to see their detailed usage. For a complete list see Special:MostLinkedTemplates, for a list of all Templates see Category:Template.

Text boxes

Code formatting

Other

See also