Help:Templates

From WikiMSK

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. See Category:Templates for a list of templates used on this website.

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 "10%", then you will enter {{example|param1=10%}}.
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 "10%", then you will enter {{example|10%}}.

Example

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

When used in the Lateral Elbow Tendinopathy article, this... ...produces:
{{condition
|image=Lateral Elbow Tendinopathy.png
|name=Lateral Elbow Tendinopathy
|synonym=Lateral Epicondylitis / Epicondylosis / Epicondylalgia, Tennis Elbow
|definition=Pain at the tendon insertion or myotendinous junction during loading of the wrist extensor muscles
|epidemiology=
|causes=
|pathophysiology=
|classification=
|primaryprevention=
|secondaryprevention=
|riskfactors=
|history=
|examination=
|diagnosis=
|tests=
|ddx=
|treatment=
|prognosis=
}}
Lateral Elbow Tendinopathy.png
Templates
Synonym Lateral Epicondylitis / Epicondylosis / Epicondylalgia, Tennis Elbow
Definition Pain at the tendon insertion or myotendinous junction during loading of the wrist extensor muscles

The other two important templates are {{procedure}} and {{study}}

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 {{condition}}, and {{procedure}}

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 topic. Navboxes are placed at the end of the article, directly after the <references /> tag.

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.
{{nonmainstream}}
Warns that the article or section contains non-evidence based content.
{{controversial}}
Warns that the article or section is controversial (but may be mainstream).
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:Guidelines page and include {{stub}}, {{partial}}, {{complete}}, and {{certified|reviewer|date}}.
Evidence Rating
You can add level of evidence statements using templates as discussed in Quality Tags. You can read more about Evidence Ratings in Evidence Ratings.

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.

Editorial Notations

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

Literature Review Template

{{Reliable sources}}
Use the {{Reliable sources}} template at the end of the article to make a box with automatically generated links to pubmed and google scholar for various types of searches. You can add synonyms by adding extra parameters e.g. {{Reliable sources|synonym1=Tennis+Elbow|synonym2="Lateral Epicondylitis"}}. Note the plus " " symbols which are important.

Other Templates

Some other notable templates include the following:

{{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. {{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|coccydynia|oodles of information|this page about coccydynia}} 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 "definition" in the {{condition}} template is referred to as {{{definition}}}.
Unnamed Parameters
Unnamed parameters are referred to by the order they are entered. For example, the first unnamed parameter that is entered in the {{example}} 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 "Unknown", use {{{1|Unknown}}}.

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:

Upercasing 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.