Help:Templates: Difference between revisions
m (→Linking) |
Serpent King (talk | contribs) (Will be a much more expanded version of Help:Templates, which I feel is severely lacking.) |
||
Line 1: | Line 1: | ||
{{ | {{Draft}} | ||
'''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== | |||
This | To use a template, the following syntax should be used: <code><nowiki>{{TemplateName}}</nowiki></code>. This is called "transclusion". For example, to use the template {{t|example}}, one would insert <nowiki>{{example}}</nowiki> in the place where the template should be included. The result will be the contents of [[Template:Example]]: | ||
{{example}} | {{example}} | ||
Sometimes, | ===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): | |||
# Supplying parameters in a unnamed list. This is typically done with templates that have only 1 or 2 parameters, such as {{t|SSB}}. To do this, simply add a bar ("|") after the template name, followed by the parameter's contents. This is to follow a <nowiki>{{TemplateName|Param1|Param2|Param3...}}</nowiki> format. | |||
#:'''Example''': <nowiki>{{SSB|Mario}}</nowiki> returns {{SSB|Mario}} | |||
# Supplying named parameters. This is usually used with templates the supply many parameters, such as {{t|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''': <nowiki>{{Head|Mario|g=SSB|s=16px}}</nowiki> returns {{Head|Mario|g=SSB|s=16px}} | |||
#:<small>*Note that this example actually uses both parameter methods.</small> | |||
===Substitution=== | ===Substitution=== | ||
=== | ==Building templates== | ||
===Conditionals=== | |||
===Expressions=== | |||
===Inclusion tags=== | |||
{{helpnav}} | {{helpnav}} | ||
Revision as of 18:35, January 22, 2016
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:
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):
- 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
- 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.