Difference between revisions of "Help:Templates"

From OutHistory
Jump to navigationJump to search
m (Protected "Help:Templates" [edit=sysop:move=sysop])
Line 1: Line 1:
Template is a page which can be inserted into another page.
+
'''Template Description:'''
  
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.
+
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.
  
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 [[Help:Namespace|namespace]] called "Template". Thus a template page would be located at "Template:Example".  
 
Templates exist in their own [[Help:Namespace|namespace]] called "Template". Thus a template page would be located at "Template:Example".  
  
To insert a simple template in a page, type
 
  
  <nowiki>{{Example}}</nowiki>
+
'''Create a simple template:'''
 +
 
 +
To create and insert a simple template in a page, type
 +
 
 +
<nowiki>{{Example}}</nowiki>
 +
 
 +
in the source of the page.
 +
 
 +
 
 +
When the page is saved, "<nowiki>{{Example}}</nowiki>" will be replaced with the contents of that template.
 +
 
  
in the source of the page. When the page is saved, "<nowiki>{{Example}}</nowiki>" will be replaced with the contents of that template.
+
'''Complex templates description:'''
  
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.
+
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")
 
To create a parametric template, surround each varialbe in tripple braces in the template page (suppose it's "Template:Biography")
 
    
 
    
  <nowiki>Biographical info - born: {{{birthyear}}}; died: {{{deathyear}}}.</nowiki>
+
<nowiki>Biographical info - born: {{{birthyear}}}; died: {{{deathyear}}}.</nowiki>
 +
 
  
 
When inserting this template into a specific page, provide values for each of the variables separated by a pipe character:
 
When inserting this template into a specific page, provide values for each of the variables separated by a pipe character:
  
  <nowiki>{{Biography|birthyear=1900|deathyear=1973}}</nowiki>
+
<nowiki>{{Biography|birthyear=1900|deathyear=1973}}</nowiki>
 +
 
  
 
The result will look like this: '''Biographical info - born: 1900; died: 1973.'''
 
The result will look like this: '''Biographical info - born: 1900; died: 1973.'''

Revision as of 09:11, 26 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 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.


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.