User:Emma/Templates
If you have any questions for me about this information or anything else about templates ask on my talk page.
Template Guidelines
This is the rules I live by for template editing and creation. As of right now they're just my own rules and NOT official policy.
Readability
The template's coding has to be properly formatted in the edit view to make it easily readable. This makes editing and debugging much easier. Line breaks that do not parse into the final template but clear up the edit view can be made with hidden comment coding: '<!-- --> as anything in them, even line breaks, are not visible or even added to the page when not in edit view.
Practicality
Do not attempt to have your template do too much by itself. This leads to clunky templates which are very difficult to debug and update. Instead break down various functions you wish to do into separate templates. Very often you will find that these separate functions will be useful in another template. And often you may find that a function you want has already been made for use.
Documentation
All templates are to have proper Purpose and Usage sections, and if desired an Example section. The Usage section should either use the NoWikiTemp template or <pre> tags to illustrate the template's parameters. The parameters should ALWAYS be described using the Parameter template.
Categorizing
The template must be properly categorized. For ease and consistency templates should be categorized using the Cat template. If a category gets too crowded, consider breaking it down into subcategories.
Usage Changes
If a template is updated to improve its usage in a way that makes all current instances of its use invalid, it is the responsibility of the editor that made the change to update each instance of the template, or to enlist help to do so.
Naming Standards
Templates are not articles. They're intended to be used as tools. So their names should be simple and if necessary abbreviations, but not too simple as to the point of being confusing. Templates are not subject to typical article standards for naming as far as capitalization is concerned. Though excess profanity is still out of the question. But it is good to maintain a format. One way is to have the name as one word, with each word that makes it up denoted by capitalizing the first letter, such as ImageLink. This saves space and is easy to read.
Template Components
Substitution
Template substitution takes all of the content of a template and adds it permanently to a page rather than transcluding it. Templates that are meant to be used this way should never have anything like Parameters in them as it includes all the template code rather than just the result.
Transclusion
Transclusion, a portmanteau of "transfer" and "include", is the process of adding a content of one page to another while still being dependent on the original pages content. So when the content on the original page changes, so does everything that it has transcluded. This is what most templates rely on to function. Those that do not use transclusion instead rely on Substitution.
Parameters
Parameters are values that a template takes in to perform certain tasks. Parameters are entered in one of two ways. The first way is the numbered, also known as unnamed, parameters; and named parameters.
Numbered Parameters
Numbered Parameters, also known as unnamed parameters, are used like: {{TemplateName|1|2|3|4|...}}, replacing the numbers with the values of the parameters. A template uses these with the calling codes: {{{1}}}, {{{2}}}, {{{3}}}, etc. In the documentation for templates, these auto-numbered parameters are normally given names to clarify the use, although in the actual coding they do not have names.
Named Parameters
Named Parameters are parameters that have been given actual names in the coding. Typically these are used when there are a lot of parameters involved and especially when there is a large mix of required and optional parameters. Named Parameters are entered in the form {{TemplateName|A=1|B=2|C=3|D=4|...}}, replacing the letters with the names of the parameters and the numbers with the values. Templates with named parameters are also sometimes entered in this format:
{{TemplateName |A=1 |B=2 |C=3 |D=4 |... }}
That format tends to be of big help when there are a large number of parameters. Named Parameters are then used by templates in this manner: {{{A}}}, {{{B}}}, {{{C}}}, {{{D}}}, etc.
Optional Parameters
Numbered and Named parameters can be made optional by adding a pipe character, a |, after the autonumber or parameter name and then entering what it is defaulted to. This isn't the only way, but it is the most basic. The other way is through more complex Parser Functions.
Parser Functions
Parser Functions are built-in Magic Words that allow for various functions to be performed. Primarily the parser functions most often used in templates are the ones added by the ParserFunctions extension. There is a lot to these functions and it would take a whole separate page to describe them all. For now you can go here
Variables
For variables on templates, they most often should be defined at the top of the template. If necessary for multiple variables, use a hidden comment line break to separate them without adding an actual line break to the template. Variables with the same name as another one are a special case. If two templates have the same named variable but have different values for it, here's how the wiki treats its value on a page:
{{TemplateA}} <!-- With a variable named Test that has a value of A, have instances of Test = {{#var:Test}}--> Test = A Test = A Test = A {{TemplateB}} <!-- Template B uses a variable named Test but does not define it. --> Test = A Test = A Test = A {{TemplateC}} <!-- Template C has variable Test AND defines it as B. --> Test = B Test = B Test = B
The variable can be used anytime after it is defined even in other templates. But once a template defines the same variable itself, the value changes to that. So templates should never conflict with each other so long as the variables are properly defined.
Types of Templates
Infobox
An Infobox is a template that contains information about a subject, usually having a picture and some descriptive statistics.
Formatting Template
A Formatting Template is a type of template used for simplifying various formatting tasks or to perform various functions. This is the most common type of template and also tend to be the most complex.
Userbox
A Userbox is a small template that contains one short statement. These are used, as the name would suggest, on userpages.
Notice Template
A Notice Template is a template that contains a critical message which is intended to draw the viewer's attention to a particular concern a page has.
Icon
An Icon is a template that puts a small image on the upper right corner of a page to state something in particular.
A Navigation Template is a template that lists various related articles. They are placed on every article it lists to, as the name implies, navigating between them easier.
Signature
A Signature is a template that holds a user's entire signature. These are intended to simplify the editing and use of a user's signature, reduce the page size of talk pages, and to clear up the edit view of talk pages of all the lengthy signature clutter. Instead of being in the Template namespace, signatures are placed in the User namespace on a subpage of the user's userpage. This simplifies and standardizes the names of the signatures and has the added benefit of automatically moving in the case of the user being renamed.
A Navigation Panel is a template that serves as a header for a page. It contains some brief information about the page's subject and a list of some relevant links. This is related to the Navigation Template. Usually these are used on userpages almost exclusively. However, Zelda Wiki.org has one that is hardcoded onto its Main Page.
Notable Templates
Zelda Wiki.org has many templates, however some really stand above the rest in usefulness and are deserving of mention.
Clear
The Clear template is an an absolute must for any article editing. All editors should be familiar with its use. It "clears" content past things like tables, div tags, images, etc., hence the name Clear.
Hide
The Hide template is a sophisticated template which allows the creation of complex templates that have content that is hidden by default but can be revealed by toggling a link.
NoWikiTemp
NoWikiTemp is an extremely useful template that is basically essential for documenting the usage of a template that is used by unnamed parameters, those being parameters that do not require the name and an equals sign. It simplfies the otherwise painful and time consuming task of formatting the usage.
Parameter
The Parameter template is absolutely essential to document any parameter used by a template. It simplifies the process of formatting the documentation of each parameter.
Image
The Image template is the absolute best way to handle images on the wiki. It improves upon the features of the default syntax and adds more options.
Cite
The Cite template standardizes the formatting of all the character quotes used as references on pages.
Main
The Main template standardizes the linking to a main article when it has a summary in another article.
Void
The Void template is an empty template which is absolutely critical in any parser function that requires a blank value. This is the single most-used template on the entire wiki, with over 10,000 pages using it.