Help:Templates: Difference between revisions

→‎Template parameters: calling. might use examples
(→‎Template parameters: calling. might use examples)
Line 9: Line 9:
===Template parameters===
===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):
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.
# Supplying parameters in a unnamed list. This is typically done with templates with a low number of 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}}
#:'''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.
# 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}}
#:'''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>
#:<small>*Note that this example actually uses both parameter methods.</small>
Parameters can then be used inside the template itself with the syntax <code><nowiki>{{{parameter name/number|text to be inserted if the parameter is not supplied}}}</nowiki></code>.


===Substitution===
===Substitution===
2,804

edits