User:Tigerpaw28/Sandbox/Template Help
What is a template? How do you use it?
[edit]A template, in the context of a wiki, is the site's way of allowing editors to build a wiki article for displaying a visual element and then include it in other articles. For example, on More_than_Meets_the_Eye,_Part_1, the infobox in the upper right is produced by adding a template to the article. The Featured character box and the Note boxes on the page are also generated using templates. These are more complex elements but templates can also be used for simpler things like displaying special characters such as the copyright symbol or adding paragraph breaks.
To use a template, you need to include a reference to it in the page you are editing. That reference will be replaced by the content produced by the template article. Generally speaking, the content will display on the page at the spot at which you placed the reference.
Anatomy of a template reference
[edit]A template reference includes several parts:
- Opening curly braces {{ - This indicates the start of the reference.
- The template name - This identifies which template you are using and can be as short as one charcter.
- Parameters - A parameter allows us to pass information to the template for the purpose of customizing the way the template displays. Going back to the example of the imfo box, there are several pieces of information passed in. The title, the image filename, the image caption, the credits, etc., are all passed in and then placed in the appropriate spot by the template.
A template can have a few paramters, many parameters or it may have no parameters at all. A parameter always starts with a pipe (|) character. Usually, this is followed by the name of the parameter, an equals sign, and then the value being passed in. Ex. "|title=More Than Meets The Eye, Part 1". However, it is not required for a parameter to have a name. In that case, the value will immediately follow the pipe character: "|More_than_Meets_the_Eye, Part 1". A template can also have a mix of named and unnamed parameters. Regardless of the type of parameter, all characters between the equals sign/pipe and the following pipe will be treated as part of the value.
- Closing curly brace }} - The opposite of it's opening counterpart, this indicates the end of the reference.
Examples: No paramters - {{c}} produces ©
Named parameters - {{hand_clock|message=Peace through templating!|width=200}}</nowki> produces {{hand_clock|message=Peace through templating!|width=200}} }} Unnamed parameters - <nowiki>{{note|Freedom is the reference of all sentient beings.}} produces
One last note with regards to template reference anatomy is that a template reference can be defined over multiple lines:
{{hand_clock |message=Peace through templating! |width=200 }}
Note that the opening braces and template name should remain on the same line. Similarly, a paramter should not be split across lines.
If the template has anonymous parameters, those parameters must be specified by number if you put the reference across multiple lines.
{{Main|Optimus Prime (G1)|Jazz (G1)|l1=Optimus Prime|l2=Jazz}}
becomes
{{Main |1=Optimus Prime (G1) |2=Jazz (G1) |l1=Optimus Prime |l2=Jazz }}
What templates are currently available?
[edit]An excellent question. One way to find out is by going to Templates. However, it's kind of difficult to sort through it due to template names being consise and therefore not necessarily self explanatory. Which is why we've created a handy reference for you.
How do I know what parameters a template has? What values should I pass?
[edit]Another great question. Each template has documentation that tells you exactly what parameters it has, what each parameter is for, and provides an example usage of the template to give you an idea of what a reference to it should look like. It will also tell you if there's anything you shouldn't do with the template or if the template might conflict with other items on the page.
How do I find the documentation?
[edit]Boy, you're full of good questions today. The template documentation is linked to from the template listed above. That documentation is actually a part of the template article (Or sometimes transcluded into with a template. Template-ception!) and that article is what's linked to in the guide.
Template coding: The Final Frontier
[edit]You want to try your hand at building a template? That's a commendable goal indeed. See Help:Building a template for instructions on how to do that.
Glossary of Terms
[edit]- Transclude/Transclusion - To transclude an article is to include it in another article.
Notes: Templates with transcluded documentation need to use includeonly to have the documentation recognized as being transcluded and linked to. MW bug? Seems to be an old bug and merely saving the tenmlate appears to fix it. Anonymous parameters need to be specified by number for multiline references

