Wikimedia/Templates

From Wikibooks, open books for an open world
< Wikimedia
Jump to navigation Jump to search

Templates are automatically generated text boxes which pipe user-entered data in a nice format which may also include a small graphic element. By typing a shortcut an editor can create a prefabricated presentation which permits a better user experience for viewers (end-users) who are not editing.

Templates in Wikimedia belong in the Template namespace. In a page, a template is surrounded by braces, such as {{Example}}. The need to type in {{Template:Example}} is negated, because the braces defaults to the Template namespace unless specified.

Templates can be displayed in two ways. You can either transclude them or substitute them. Normally, a template is transcluded, which shows the version on the original page. If the source page is updated, the template is updated. Substitution copies over the source code of a page as it is. Instead of viewing a page with the parameters specified, it directly pastes the code for the template into the page. The substituted code does not change if the source page changes.

To specify parameters in a template, you use the symbol I This separates the template name/another parameter from the current parameter. Normally, you have to mane the given parameter. For example, if {{Example}} requires a name, then you will have to specify a name by using a parameter, such as {{Example|name=A name}}. If no name is specified, then {{Example|A name}} is the same as {{Example|1=A name}}.