Difference between revisions of "Help:Templates"

From OutHistory
Jump to navigationJump to search
m (added "help pages" category)
m (Protected "Help:Templates" [edit=sysop:move=sysop])
(No difference)

Revision as of 12:00, 31 March 2008

Template is a page which can be inserted into another page.

Templates are useful for any text for which one wants a copy in two or more pages, and there is no need for each copy to be edited independently. Since parameters can be used, versions may to that extent even be different, and parameter values can be edited independently for each. Templates are not only convenient, but they can also "force" a useful uniformity.

If a template page is edited, all the pages which contain the template in them will be updated accordingly. Templates can be used to save repetitive typing in standardized template messages, info boxes, etc.

Templates exist in their own namespace called "Template". Thus a template page would be located at "Template:Example".

To insert a simple template in a page, type

 {{Example}}

in the source of the page. When the page is saved, "{{Example}}" will be replaced with the contents of that template.

Templates can contain parameters. For example, a biography may contain a info box with a year of birth and a year of death, and these two parameters could be passed to the page allowing the text of each template to be different.

To create a parametric template, surround each varialbe in tripple braces in the template page (suppose it's "Template:Biography")

 Biographical info - born: {{{birthyear}}}; died: {{{deathyear}}}.

When inserting this template into a specific page, provide values for each of the variables separated by a pipe character:

 {{Biography|birthyear=1900|deathyear=1973}}

The result will look like this: Biographical info - born: 1900; died: 1973.