Help:Templates: Difference between revisions

From SmashWiki, the Super Smash Bros. wiki
Jump to navigationJump to search
Line 18: Line 18:


==Building templates==
==Building templates==
Templates can be created by making a page in the template namespace. To do this, simply create Template:TemplateName.
===Parameters===
===Parameters===
===Conditionals===
===Conditionals and expressions===
===Expressions===
====#if====
====#ifeq====
====#iferror====
====#ifexpr====
====#ifexist====
====#switch====
====#expr====
===Inclusion tags===
===Inclusion tags===
====includeonly====
====noinclude====
====only include====


{{helpnav}}
{{helpnav}}

Revision as of 23:50, January 22, 2016

Proposed.png
This page is a draft.
Feel free to contribute to this page as you would a mainspace page.

Templates are tools used in our articles that serve to both provide consistency and simplify the editing process. They may be used to quickly and easily build tables or infoboxes, or they could be used as link shortcuts. For a list of usable templates, see Category:Templates.

Using templates

To use a template, the following syntax should be used: {{TemplateName}}. This is called "transclusion". For example, to use the template {{example}}, one would insert {{example}} in the place where the template should be included. The result will be the contents of Template:Example:

Correct
The template was successfully included in this page.

Template parameters

Sometimes, a template will have required or optional parameters that need to be specified on the template's use. There are 2 methods of supplying parameters (which one should be used depends on the template in question):

  1. Supplying parameters in a unnamed list. This is typically done with templates that have only 1 or 2 parameters, such as {{SSB}}. To do this, simply add a bar ("|") after the template name, followed by the parameter's contents. This is to follow a {{TemplateName|Param1|Param2|Param3...}} format.
    Example: {{SSB|Mario}} returns Mario
  2. Supplying named parameters. This is usually used with templates the supply many parameters, such as {{Head}}. To do this, still add the bar, but instead of inserting the parameter's contents right away, add the parameter name (specified by the template) followed by an equals sign ("="), then the parameter's contents.
    Example: {{Head|Mario|g=SSB|s=16px}} returns Mario's head icon from SSB.
    *Note that this example actually uses both parameter methods.

Substitution

Building templates

Templates can be created by making a page in the template namespace. To do this, simply create Template:TemplateName.

Parameters

Conditionals and expressions

#if

#ifeq

#iferror

#ifexpr

#ifexist

#switch

#expr

Inclusion tags

includeonly

noinclude

only include