Help:Templates: Difference between revisions

From Zelda Wiki, the Zelda encyclopedia
Jump to navigation Jump to search
m (→‎Transclusion and substitution: Clearing up what appears to have been a tiny typo/mixup. Generally templates should not be transcluded? No, rather generally they should not be substituted...)
 
Line 34: Line 34:
{{Small|In reality, [[Template:MM]] outputs something quite different when substituted, but this illustrates the point.}}
{{Small|In reality, [[Template:MM]] outputs something quite different when substituted, but this illustrates the point.}}


Generally, templates should be substituted and not transcluded. Substitution does not preserve a reference to the template—it's like you didn't use a template at all. You lose the ability to have the content update automatically when you change the template.
Generally, templates should be transcluded and not substituted. Substitution does not preserve a reference to the template—it's like you didn't use a template at all. You lose the ability to have the content update automatically when you change the template.


==Making Templates==
==Making Templates==
For information on how to ''make'' templates, see [[Zelda Wiki:Making Templates]].
For information on how to ''make'' templates, see [[Zelda Wiki:Making Templates]].

Latest revision as of 01:41, 19 December 2022

Zelda Wiki's
Help Guide
Basic Editing:

Getting Started
Citing Sources
Images and Uploading
Initialisms
Protected Pages
Redirects
Talk Pages
Templates (Template List)

Guidelines and Policies:

Canon Policy
Editing Etiquette
Image Deletion Policy
Inter-Wiki Policy
Nintendo Article Guidelines
Quality Standards
User Accounts
User Conduct

Advanced Editing:

Archiving Talk Pages
Article Reorganization
Custom Signatures
Keyboard Shortcuts
Merging and Moving Pages
Patrolling
Tables
User Navigation Bars
WikiExclusives

General Information

Staff
User Rights
About
Glossary

See also: Help:Templates on MediaWiki

A template is a page made to be included in other pages. They standardize content or formats that need to be repeated on many pages, by encapsulating them in a separate page in the Template namespace. They can abstract away complicated syntax, namely parser functions.

Templates are most often used by transclusion. That is, by enclosing the name of the template page in {{double curly brackets}}. When placed in another page, the entire contents of that template page will be displayed where you placed it. Templates can have parameters that modify their appearance or content.

An example of a common template is an infobox, such as Template:Infobox Item. Infobox templates appear in the upper right corner of nearly every article on the wiki. There are many other types of templates.

Using Templates

Parameters

Templates can have anonymous parameters, named parameters, or both. With anonymous parameters, order matters.

Template:Color is a template with anonymous parameters. It is used like this: {{Color|TWWHD Vermilion|merchant's oath}}, which produces merchant's oath. You wouldn't get the right output if you changed the order of the parameters.

Template:Clarify is a template with both anonymous and named parameters. It is used like this: {{Clarify|BotW|reason= Some text here}}. There's one anonymous parameter for the game, and a named reason parameter for the display text.

Transclusion and substitution

Templates can be used by transclusion or by substitution. When you transclude a template on a page and save it, the source will still show {{<Template name>}} when you go back to edit it. Conversely, when you substitute a template, the actual contents of the template gets copied and saved to the page.

Transclusion vs. substitution after saving the page
Input Output view Output source
{{MM}} Majora's Mask {{MM}}
{{subst:MM}} Majora's Mask ''[[The Legend of Zelda: Majora's Mask|Majora's Mask]]''

In reality, Template:MM outputs something quite different when substituted, but this illustrates the point.

Generally, templates should be transcluded and not substituted. Substitution does not preserve a reference to the template—it's like you didn't use a template at all. You lose the ability to have the content update automatically when you change the template.

Making Templates

For information on how to make templates, see Zelda Wiki:Making Templates.