Template:Help:Template parameters

Ashes of Creation community empowered Wiki
Jump to navigation Jump to search

Parameters are used to pass information to a template when it is embedded. Parameters allow the template to produce different contents or have different behaviors.

Suppose you wish to insert a thank you note on a page with the name of the person being thanked embedded in the text. Create a template called "Template:Thankyou" as follows:

Thank you for your help with the wiki {{{1}}}!

You can then use this template by specifying the person's name as a parameter to it:

{{Thankyou|Rick}}

Notice the use of {{{1}}}. This is the way to identify, within templates, the parameters that will be passed in when the template is used. Note that, within the template, each parameter is surrounded by three braces: {{{ }}}.

When using the template on a page, you fill in the parameter values, separated by a "pipe" character (|).

The result will appear as:

Thank you for your help with the wiki Rick!

Default parameter values

Suppose we add a second parameter to the last example, to say who the thank you is from. Such as:

Thank you for your help with the wiki {{{1}}}!<br/>
From {{{2}}}.

If the template is called without the second parameter {{Thankyou|Rick}}, the result would be

Thank you for your help with the wiki Rick!
From .

To avoid this situation, you can use a default parameter value inside the template. The output will take on this value if the parameter is not being passed.

Thank you for your help with the wiki {{{1}}}!<br/>
From {{{2|the wiki team}}}.

Now if the template is called without the second parameter, the result would be

Thank you for your help with the wiki Rick!
From the wiki team.