Help:Template parameters

Templates allow you to pass parameters that can be used to affect the content or design of the template.

Simple replacement
Using the example of a simple box, the following when placed on a template page called :

Template code


Produces the following box on the template page:



Article code
Next, on an article, you could type:

This would produce:

something

This is because  tells the wiki to pass the first parameter of the template here. This can be extended with,  , ad infinitum. The number represents the number of the parameter:

If you wish not to use a certain parameter, you can leave it blank, but the | must still be included. For example:

Named and default parameters
As an alternative to the above, you can use named parameters. Though this makes the code slightly more complex, it allows more freedom in how templates are created.

Template code
Again, using the example of Template:Box:



introduces the concept of a named parameter. also introduces the concept of a default parameter - if bgcolor is not defined, #666 will be passed.

Article code
Produces:

A yellow box

As the parameters have names, you can pass them in any order, so  would produce an identical box.

Due to default parameters, if, say, the background color was not defined - as in  - you would get:

A yellow box