1,770
edits
(→Learn more: Transclusion & substitution section) |
(other pages section; intro redo; - see below for inclusion tags (might make a new page); typos) |
||
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 === | === 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. | 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. The code may be copy-pasted, but this might break it. For example, the inclusion tags | 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> | For example, if [[Template:Mirror universe]] is substituted to a page, the template call would be replaced by the following code:<br> | ||
Line 64: | Line 62: | ||
<div style="padding: 5px 10px 5px; border-left: 5px solid lightpink;">In source editing, safe substitution is executed with word <code>safesubst:</code> in the template call, e.g. <code><nowiki>{{safesubst:Mirror universe}}</nowiki></code></div> | <div style="padding: 5px 10px 5px; border-left: 5px solid lightpink;">In source editing, safe substitution is executed with word <code>safesubst:</code> in the template call, e.g. <code><nowiki>{{safesubst:Mirror universe}}</nowiki></code></div> | ||
Note that substitution and safe substitution will increase the | Note that substitution and safe 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 safe substitution in particular may defeat the purpose. | ||
The wikicode of a template may also be called. | 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> | <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>{{safesubst::Tristan Wolf}}</nowiki></code></div> | |||
=== More on the topic === | === More on the topic === |
edits