Wikishire:Templates

From Wikishire
Jump to navigation Jump to search

Templates are a short way to add a repeated text or procedure within a page. It may be placed on the page or within another template. A template is written in the same manner as an article, but the page name begins "Template:", and on the edit screen the name (without "Template:") appears in double braces {{  }}

A basic template may be used to add a recurrant message to a page or a recurrant lay-out. Also though, a template may function as a programmed routine, or as a mixture of all three. A template may stand on its own or it may have "parameters", which make the template routine function differently according to the parameters given to it.

Editing and using templates

You start a new template in the same way you would start an article page. The only difference is that its title must start with Template:.

To add a Template to a page during editing, add {{templatename}} to the page on which you want to use it. If the Template needs parameters, do not forget to give it the parameters, for example:

{{port}} Adds the category for a port in the relevant county.
{{port|major}} Gives it the "Major port" categories
{{convert|8|km|mi|0|x}} Has 5 parameters: it converts 8 from km to miles with 0 decimal places and omits (x) the metric measurement.

Some templates have a "/doc" page attached to them to explain their use and the parameters they require.

When editing a template, remember that it will change every page on which the template appears.

Parameters

Templates can have parameters. Instead of just the template name, like {{foo}}, a template with parameters will have additional text, separated by vertical bars (|), for example {{foo|July|lc=yes}}. Here "July" is the value of the first unnamed parameter; "yes" is the value of the parameter "lc". Writing the template page for a template with parameters is more complicated than for a template with no parameters.

Major examples of use

Existing templates

Further help

For help on programming templates, look initially at: