Help:Templates

From The Coppermind
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Contents | Getting Started | Guidelines | Markup | References | Images | Categories | Templates | What Now?

Templates make more complicated and repetitive editing tricks easier to do. This page will explain how to create and use them. For more details, see Wikipedia's Help page on Templates.

Using Templates

Most templates that you may need to use already exist, so let's talk about using them first.

Templates are enclosed by double curly braces ({{ and }}). The template name comes first, followed by parameters, all separated by vertical bars (|). It looks something like this: {{name|param1|param2|param3}}.

Note that some templates are entered in a single line of text, like the example above. This is common for reference templates and those which don't require any parameters. However, it is not uncommon for templates to span multiple lines, for the sake of clarity. Something more like:

{{name
|param1
|param2
|param3
}} 

Parameters

There are two kinds of parameters: named and unnamed. Named parameters are identified by the name of the parameter while unnamed parameters are identified simply by the order they appear.

Named Parameters
Named parameters require the parameter name and an equals sign (=) followed by your input. If param1 is a named parameter of {{example}}, and you want the input to be "Mistborn", then you will enter {{example|param1=Mistborn}}.
Unnamed Parameters
Unnamed parameters should be completely replaced by your input. If param1 is an unnamed parameter of {{example}}, and you want the input to be "Mistborn", then you will enter {{example|Mistborn}}.

Example

Let's look at an example using the {{character}} template, which is used to create the infobox at the top of articles about characters. It creates a table with information that commonly pertains to characters. The different fields of the table are entered as parameters.

When used in the Kelsier article, this... ...produces:
{{character
|image=Kelsier.jpg
|abilities=[[Allomancy|Mistborn]] 
|spouse=[[Mare]]
|siblings=[[Marsh]]
|titles=Survivor 
|born=c. 984 FE
|world=Scadrial
|ethnicity=Skaa
|residence=Luthadel
|books=[[Mistborn (series)]]
}}
Kelsier
Kelsier.jpg
Family
Spouse Mare
Siblings Marsh
Born c. 984 FE
Abilities Mistborn
Titles Survivor
Ethnicity Skaa
Residence Luthadel
World Scadrial
Featured In Mistborn (series)

Types of Templates

Let's go over the common types of templates you may encounter and make use of.

Information Boxes

Called infoboxes for short, these templates create the tables at the upper right hand corner of articles. They display important facts and details which are common to articles of the same category. Infoboxes are placed at the start of the article. There are infobox templates for all of the high level content categories, and a few others that are more specific. Common examples include {{book}}, {{character}}, {{magic system}}, and {{location}}.

For more detailed help on infoboxes in general see Help: Infoboxes and for a full list of infobox templates, see Category: Infoboxes.

Navigation Boxes

Called navboxes for short, these templates create the tables at the bottom of pages that link to other important articles that are related to the same book or series. Most series or standalone books have a navbox that refers to important characters, places, etc. Navboxes are placed at the end of the article, directly after the <references /> tag. Common examples include {{Cosmere}}, {{Stormlight}}, and {{Reckoners}}.

For a full list of navbox templates, see Category:Navbars.

Notices

Notice templates alert users and editors of important information regarding the page itself. Some notable notice templates are listed below. For a full list of notice templates, see Category:Notices.

{{attention}}
Makes note at top of page that article needs attention and categorizes the article accordingly. Place directly after infobox.
{{copyright}}
Asks users not to copy the content on the article.
{{theory}}
Warns that the article or section contains speculation and should not be considered canon. Place directly after infobox or directly after section heading.
{{spoilers}}
Warns that the article contains information pertaining to recently published material that many users may not have read yet. Place directly after infobox.
{{delete}}
Requests that an administrator delete the page.
{{move}}
Requests that an administrator move the page (change the title). An unnamed parameter may be included to indicate which page it should be moved to.
Quality Tags
Quality tags are simple templates that indicate the level of completion/quality of an article and categorize it accordingly. These are discussed in detail on the Help:Categories page and include {{stub}}, {{partial}}, and {{complete}}

Reference Templates

Reference templates are used to cite the source of information in an article. They create a superscript number that links to the footnotes in the "Notes" section, where the full reference is provided. For more on reference templates, see Help:References.

Link Macros

Link macros are templates which link to something that's related to the input. They often categorize the article as well. For a full list of link macros, see Category:Link macros.

Editorial Notations

Editorial notations are used to highlight information which is unsupported, ambiguous, or questionable. For more, see Help:References.

Other Templates

Some other notable templates include the following:

{{b}}
This is a simple template that outputs a full book or series title given an abbreviated or shorthand reference. For example, "{{b|sa1}}" returns "The Way of Kings" (i.e. Stormlight Archive book 1).
{{columns}}
Use the {{columns}} template to create columns. Use {{columns|count=N|TEXT}}, where N is the desired number of columns and TEXT is the content to be split up into columns. Separate items in TEXT by using line breaks or lists. Note that |count=N may be omitted; the number of columns is 3 by default.
This... ...produces:
{{columns|count=2|
* Item 1
* Item 2
* Item 3
* Item 4
* Item 5
}}
  • Item 1
  • Item 2
  • Item 3
  • Item 4
  • Item 5
{{quote}}
Use {{quote}} to highlight some text as a quote. Use {{quote|TEXT|SOURCE}}, where TEXT is the quote itself and SOURCE is the source of the quote (typically the name of the speaker or a short description of the context, followed by a reference). {{quote|Do or do not. There is no try.|Yoda}} produces:

Do or do not. There is no try.

—Yoda
{{sidequote}}

Do or do not. There is no try.

—Yoda
Use {{sidequote}} to place a quote on one side of the page, with text floating around it. Use {{sidequote|TEXT|SOURCE|POSITION|WIDTH}}, where TEXT is the quote itself, SOURCE is the source of the quote, POSITION is the alignment of the quote (left or right), and WIDTH is some number followed by "px", to specify the width of the quote in pixels. When placed at the top of this paragraph, {{sidequote|Do or do not. There is no try.|Yoda|side=right|size=300px}} produces the quote to the right.
{{for}}
This template provides a quick and clean way to refer to other articles. It generally takes one unnamed parameter, {{{1}}}, as input. By default, it returns "For more information, see {{{1}}}", where {{{1}}} is a link to the referenced article. A second unnamed parameter will replace "more information" and a third will replace the text which refers to the linked article. For example, {{for|cosmere|oodles of information|this page about the cosmere}} produces:

Template Pages

Templates are created just like articles and categories: you create a page for one in the Template namespace. You should find documentation for a template on this page. It will provide a description of what the template does, a list of required and acceptable parameters, and occasionally some examples.

Editing Templates

Editing templates (or creating one from scratch) is definitely not a task for beginners. But we'll go over some of the basics.

Includeonly and Noinclude

<includeonly> Tag
Everything you want the template to do when used on other pages should be sandwiched between <includeonly> and </includeonly> tags.
<noinclude> Tag
The template's documentation, and anything else you want to show up on the template page itself, must be sandwiched between <noinclude> and </noinclude> tags.

Parameters

Named Parameters
Named parameters are referred to by their name in triple braces. For example, the named parameter "books" in the {{character}} template is referred to as {{{books}}}.
Unnamed Parameters
Unnamed parameters are referred to by the order they are entered. For example, the first unnamed parameter that is entered in the {{book ref}} template is referred to as {{{1}}}, while the second is referred to as {{{2}}}.
Defaults
Provide a default value for parameters by including a vertical bar (|) followed by the default value. To use a null default value, enter nothing after the vertical bar. For example, if you want the first unnamed parameter to have a default value of "Sanderson", use {{{1|Sanderson}}}.

Parser Functions

There are a number of functions that can be used to generate different results based on the input provided. For an extensive list, see MediaWiki's Parser Functions page. Here are some of the basics:

Uppercasing Text
This function converts a string of text to all uppercase.
Use: {{uc: TEXT}}, where TEXT is the text to be converted.
Example: {{uc: heLLo}} produces HELLO.
Lowercasing Text
This function converts a string of text to all lowercase.
Use: {{lc: TEXT}}, where TEXT is the text to be converted.
Example: {{lc: heLLo}} produces hello.
String Compare
This function compares two strings of text and provides one of two results.
Use: {{#ifeq: A|B|Result1|Result2}}, where A and B are the strings of text. If A=B then Result1 is returned; otherwise, Result2 is returned.
Example: {{#ifeq: dog|dog|same|different}} produces same and {{#ifeq: dog|cat|same|different}} produces different.
If-Then
This function checks if a parameter exists and provides one of two results.
Use: {{#if: A|Result1|Result2}}, where A is some parameter. If A exists (i.e. it isn't null) then Result1 is returned; otherwise, Result2 is returned.
Example: If a second unnamed parameter is provided, {{#if: {{{2|}}}|hello|goodbye}} produces hello. If not, it produces goodbye.
Case-Switch
This function performs a series of string compares until a "true" result is found.
Use: {{#switch: X|A=Result1|B=Result2|C=Result3|etc.|Default}}, where X is compared to A, B, and so on. The first match provides the corresponding result. A final, default result may be provided in case no match is found.
Example: {{#switch: cat|dog=bark|cat=meow|growl}} produces meow and {{#switch: bear|dog=bark|cat=meow|growl}} produces growl.

System Variables

There are a few system variables which provide different values as needed. These are given in all caps between double curly braces. For an extensive list, see MediaWiki's Magic Words page. The two most common are:

Pagename
{{PAGENAME}} provides the name of the page/article. If used in this page it would yield Templates.
Namespace
{{NAMESPACE}} provides the name of the page's namespace. If used in this page it would yield Help.

Comments

Comments inside of <includeonly> tags can be provided between <!-- and -->.

Note: You might see a lot of these in existing templates, at the beginning and end of each line. White space can do strange things in templates, and so it is best to eliminate unnecessary white space by putting it inside of comments. One notable exception is inside tables, between the |- and the first cell |, which means the infobox {{row/kv}} (et al) can be nicely spaced without consequence.


New Editor's Guide
Categories Templates What now?