1,903
edits
(colourcoding for visual & source editors; small language changes) |
(removed safesubst (got it a bit wrong + less relevant to the topic)) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
{{Help page}} | {{Help page}} | ||
'''Templates''' are bits of code that make using the wiki easier. They are used in nearly every page in 118Wiki, including the very basic character pages. This guide explains what the templates are and how to use them on a page. | |||
{{LCARS-bar-heading|What is a template?|COLOR={{Color|red}}}} | {{LCARS-bar-heading|What is a template?|COLOR={{Color|red}}}} | ||
Line 48: | Line 48: | ||
{{LCARS-bar-heading|Learn more|COLOR={{Color|blue}}}} | {{LCARS-bar-heading|Learn more|COLOR={{Color|blue}}}} | ||
{{ | === Transclusion and substitution === | ||
As described above, adding a template to a page using a template call (such as <code><nowiki>{{Mirror universe}}</nowiki></code>) is called ''transclusion''. Each time the page is opened, the current form of the template is displayed. | |||
Sometimes, it is more desirable that the display doesn’t change but is static or that it may be modified for the purpose of that one page. The code may be copy-pasted, but this might break it. For example, the inclusion tags should be removed by the user by hand. Instead of copy-pasting, ''substitution'' should be used. When the page is saved, substitution replaces the template call with the template code as it would appear had the template merely been transcluded. | |||
For example, if [[Template:Mirror universe]] is substituted to a page, the template call would be replaced by the following code:<br> | |||
<nowiki>:''This article pertains to a subject of the [[Mirror universe]].''[[File:Mirror-universe.jpg|x40px|link=Category:Mirror universe]]<br clear=all></nowiki> | |||
Now, should the template be edited, the display on the page won’t change. Note that the code of the template in its template page has a line <code><nowiki><noinclude>[[Category:Mirror universe]]</noinclude></nowiki></code>. Since this line is not included in the transclusion, it won’t be in the substitution either. | |||
<div style="padding: 5px 10px 5px; border-left: 5px solid lightpink;">In source editing, substitution is executed with word <code>subst:</code> in the template call, e.g. <code><nowiki>{{subst:Mirror universe}}</nowiki></code></div> | |||
Note that substitution will increase the length of the wikicode on page considerably and might make difficult to edit. Some templates are designed so that they are dynamic, so substitution may defeat the purpose. | |||
The wikicode of a template may also be called. | |||
<div style="padding: 5px 10px 5px; border-left: 5px solid lightpink;">In source editing, wikicode call is executed with word <code>msgnw:</code> in the template call, e.g. <code><nowiki>{{msgnw:Mirror universe}}</nowiki></code></div> | |||
=== Other pages === | |||
This help page has concentrated on templates, but everything stated here about templates applies to any other page as well! For example, the contents of an article may be transcluded or substituted to another page. For example, many crew listings depend on character ID pages, such as [[Tristan Wolf/ID]], which doesn’t have the “Template:” prefix and isn’t therefore a template. | |||
<div style="padding: 5px 10px 5px; border-left: 5px solid lightpink;">When transcluding or substituting a page other than a template, the template call is slightly different in source editing. The prefix “Template:” is left out, but the ''namespace'' prefix should be used for any other type of page. For example, this help page is called with <code><nowiki>{{Help:Templates}}</nowiki></code>. For main namespace (articles), the namespace prefix is empty, so only a colon : is used, for example <code><nowiki>{{:Tristan Wolf}}</nowiki></code> for [[Tristan Wolf]]. | |||
Substitution of another page works similarly, but with <code><nowiki>subst:</nowiki></code> (or equivalent) ahead of the namespace prefix, e.g. <code><nowiki>{{subst:Help:Templates}}</nowiki></code> or <code><nowiki>{{subst::Tristan Wolf}}</nowiki></code></div> | |||
=== More on the topic === | === More on the topic === | ||
Line 57: | Line 78: | ||
* [https://www.mediawiki.org/wiki/Help:Templates Templates], MediaWiki help page about templates | * [https://www.mediawiki.org/wiki/Help:Templates Templates], MediaWiki help page about templates | ||
* [https://en.wikipedia.org/wiki/Help:Template Template], Wikipedia help page about templates | * [https://en.wikipedia.org/wiki/Help:Template Template], Wikipedia help page about templates | ||
* [https://www.mediawiki.org/wiki/Help:Substitution Substitution], MediaWiki help page about substitution | |||
{{End Columns}} | {{End Columns}} | ||
[[Category:Help]] | [[Category:Help]] |
edits