Difference between revisions of "Help:Templates"
Line 28: | Line 28: | ||
<nowiki>{{ShortNameOfTemplate}}</nowiki> | <nowiki>{{ShortNameOfTemplate}}</nowiki> | ||
− | When the page is saved, "<nowiki>{{ | + | When the page is saved, "<nowiki>{{ShortNameOfTemplate}}</nowiki>" will be replaced with the contents of that template. The contents of the template are created by going to the template page with the brief name you have chosen, filling in the particular content, and saving the template page. |
Revision as of 10:32, 30 June 2008
Template Description:
A 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 in templates, versions may to that extent 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".
Create a simple template:
To create and insert a simple template in an existing page, type a clear, abbreviated, short name for the template in the existing page and surround it by two brackets like those below:
{{ShortNameOfTemplate}}
When the page is saved, "{{ShortNameOfTemplate}}" will be replaced with the contents of that template. The contents of the template are created by going to the template page with the brief name you have chosen, filling in the particular content, and saving the template page.
Complex templates description:
Templates can contain parameters. For example, a biography may contain an 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 complex template:
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.