Sarna News: Bad 'Mechs - Icestorm
Help page: Edit

Editing Help:Transclusion

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 18: Line 18:
  
 
==Transclusion syntax==
 
==Transclusion syntax==
The general [[w:Syntax (programming languages)|syntax]] for [[w:Transclusion|transclusion]] on BattleTechWiki is <code><nowiki>{{</nowiki>[[BTW:Namespace|Namespace]]:[[BTW:Page name|Pagename]]<nowiki>}}</nowiki></code>, where <code>Namespace:Pagename</code> describes the title of a BattleTechWiki page.  
+
The general [[Syntax (programming languages)|syntax]] for [[w:Transclusion|transclusion]] on BattleTechWiki is <code><nowiki>{{</nowiki>[[BTW:Namespace|Namespace]]:[[BTW:Page name|Pagename]]<nowiki>}}</nowiki></code>, where <code>Namespace:Pagename</code> describes the title of a BattleTechWiki page.  
  
Using transclusion syntax requires some knowledge of page titles. On BattleTechWiki, non-article pages have titles with a visible namespace and pagename separated by a colon; for example, the page [[BattleTechWiki:Templates]] has <code>BattleTechWiki</code> as the namespace, and <code>Tips</code> as the pagename. But encyclopedic articles only have a visible pagename in their titles: for example the article [[Example]] has <code>Example</code> as the pagename, and the namespace, called [[BattleTechWiki:Namespace|main namespace]], is not visible.
+
Using transclusion syntax requires some knowledge of page titles. On BattleTechWiki, non-article pages have titles with a visible namespace and pagename separated by a colon; for example, the page [[BattleTechWiki:Tips]] has <code>BattleTechWiki</code> as the namespace, and <code>Tips</code> as the pagename. But encyclopedic articles only have a visible pagename in their titles: for example the article [[Potato]] has <code>Potato</code> as the pagename, and the namespace, called [[BattleTechWiki:What is an article?#Namespace|main namespace]], is not visible.
  
 
* The [[Help:Wikitext|wikitext]] <code><nowiki>{{</nowiki>Namespace:Pagename<nowiki>}}</nowiki></code> will transclude the page titled <code><nowiki>Namespace:Pagename</nowiki></code>. For example, if a page has the wikitext <code><nowiki>{{</nowiki>BattleTechWiki:Notability<nowiki>}}</nowiki></code> in it, it will transclude the page [[BattleTechWiki:Notability]] into it. Please note that <code><nowiki>{{</nowiki>BTW:Notability<nowiki>}}</nowiki></code> would do exactly the same thing, as <code>BTW:</code> is a [[BattleTechWiki:Namespace#Aliases|namespace alias]], which is [[BattleTechWiki:Shortcut#Namespace_aliases|automatically translated]] by the BattleTechWiki servers to <code>BattleTechWiki:</code>.
 
* The [[Help:Wikitext|wikitext]] <code><nowiki>{{</nowiki>Namespace:Pagename<nowiki>}}</nowiki></code> will transclude the page titled <code><nowiki>Namespace:Pagename</nowiki></code>. For example, if a page has the wikitext <code><nowiki>{{</nowiki>BattleTechWiki:Notability<nowiki>}}</nowiki></code> in it, it will transclude the page [[BattleTechWiki:Notability]] into it. Please note that <code><nowiki>{{</nowiki>BTW:Notability<nowiki>}}</nowiki></code> would do exactly the same thing, as <code>BTW:</code> is a [[BattleTechWiki:Namespace#Aliases|namespace alias]], which is [[BattleTechWiki:Shortcut#Namespace_aliases|automatically translated]] by the BattleTechWiki servers to <code>BattleTechWiki:</code>.
*If the namespace is omitted, but the colon is included, like <code><nowiki>{{</nowiki>:Pagename<nowiki>}}</nowiki></code>, the encyclopedic article <code>Pagename</code> will be transcluded. For example, <code><nowiki>{{</nowiki>:Example<nowiki>}}</nowiki></code> will transclude the article [[Example]].
+
*If the namespace is omitted, but the colon is included, like <code><nowiki>{{</nowiki>:Pagename<nowiki>}}</nowiki></code>, the encyclopedic article <code>Pagename</code> will be transcluded. For example, <code><nowiki>{{</nowiki>:Notability<nowiki>}}</nowiki></code> will transclude the article [[Notability]].
*If both namepace and colon are omitted, like <code><nowiki>{{</nowiki>Pagename<nowiki>}}</nowiki></code>, the <code>Template:Pagename</code> will be transcluded. For example <code><nowiki>{{</nowiki>Example<nowiki>}}</nowiki></code>, and also <code><nowiki>{{</nowiki>Template:Example<nowiki>}}</nowiki></code>, will both transclude the [[Template:Example]].
+
*If both namepace and colon are omitted, like <code><nowiki>{{</nowiki>Pagename<nowiki>}}</nowiki></code>, the <code>Template:Pagename</code> will be transcluded. For example <code><nowiki>{{</nowiki>Notability<nowiki>}}</nowiki></code>, and also <code><nowiki>{{</nowiki>Template:Notability<nowiki>}}</nowiki></code>, will both transclude the [[Template:Notability]].
  
 
So, in summary, an example page having the wikitext <code><nowiki>{{</nowiki>Pagename<nowiki>}}</nowiki></code> or <code><nowiki>{{</nowiki>Template:Pagename<nowiki>}}</nowiki></code> included, will transclude the <code>Template:Pagename</code> into that example page. But <code><nowiki>{{</nowiki>:Pagename<nowiki>}}</nowiki></code> will have a different effect: it will transclude the article <code>Pagename</code>. Also, <code><nowiki>{{</nowiki>Namespace:Pagename<nowiki>}}</nowiki></code> will transclude the page <code><nowiki>Namespace:Pagename</nowiki></code>, for pages with titles of that format. You also have the option of using [[#Template parameters|template parameters]] and [[#Transclusion modifiers|transclusion modifiers]].
 
So, in summary, an example page having the wikitext <code><nowiki>{{</nowiki>Pagename<nowiki>}}</nowiki></code> or <code><nowiki>{{</nowiki>Template:Pagename<nowiki>}}</nowiki></code> included, will transclude the <code>Template:Pagename</code> into that example page. But <code><nowiki>{{</nowiki>:Pagename<nowiki>}}</nowiki></code> will have a different effect: it will transclude the article <code>Pagename</code>. Also, <code><nowiki>{{</nowiki>Namespace:Pagename<nowiki>}}</nowiki></code> will transclude the page <code><nowiki>Namespace:Pagename</nowiki></code>, for pages with titles of that format. You also have the option of using [[#Template parameters|template parameters]] and [[#Transclusion modifiers|transclusion modifiers]].
Line 40: Line 40:
 
* You also have the option of using [[#Template parameters|template parameters]] and [[#Transclusion modifiers|transclusion modifiers]]
 
* You also have the option of using [[#Template parameters|template parameters]] and [[#Transclusion modifiers|transclusion modifiers]]
  
For example, to transclude [[Template:Aye/doc]], it would be either <code><nowiki>{{Template:Aye/doc}}</nowiki></code> or <code><nowiki>{{Aye/doc}}</nowiki></code>. Note that subpage names are case sensitive, and <code><nowiki>{{Aye/Doc}}</nowiki></code> would not work.
+
For example, to transclude [[Template:Like/doc]], it would be either <code><nowiki>{{Template:Like/doc}}</nowiki></code> or <code><nowiki>{{Like/doc}}</nowiki></code>. Note that subpage names are case sensitive, and <code><nowiki>{{Like/Doc}}</nowiki></code> would not work.
  
 
===Template parameters===
 
===Template parameters===
Line 47: Line 47:
 
{{for|a quick guide to templates|Help:A quick guide to templates}}
 
{{for|a quick guide to templates|Help:A quick guide to templates}}
  
The most common application of transclusion is the transclusion of [[Help:Template|templates]]. Templates are pages that are written with the prime objective of being included in other pages, either through transclusion or [[Help:Substitution|substitution]]. As shown above, the usual syntax for transcluding a template titled Template:Pagename is <code><nowiki>{{Pagename}}</nowiki></code>. However, some templates can also use [[w:parameter|parameter]]s. Parameters are [[w:Variable (computer science)|variables]] that can be given values (also termed [[w:Parameter_(computer_programming)#Parameters_and_arguments|arguments]]) that can be passed on to certain templates in order for them to work in different ways. Templates can either use no parameters, a fixed number of parameters, or a variable number of parameters. The number of parameters a template can use is from one upwards.
+
The most common application of transclusion is the transclusion of [[Help:Template|templates]]. Templates are pages that are written with the prime objective of being included in other pages, either through transclusion or [[Help:Substitution|substitution]]. As shown above, the usual syntax for transcluding a template titled Template:Pagename is <code><nowiki>{{Pagename}}</nowiki></code>. However, some templates can also use [[parameter]]s. Parameters are [[Variable (computer science)|variables]] that can be given values (also termed [[Parameter_(computer_programming)#Parameters_and_arguments|arguments]]) that can be passed on to certain templates in order for them to work in different ways. Templates can either use no parameters, a fixed number of parameters, or a variable number of parameters. The number of parameters a template can use is from one upwards.
  
 
The exact syntax for using parameters with templates can vary greatly, depending on the actual template being used. But, for an example template titled Template:Pagename, which happened to use three parameters, the general form would be:  
 
The exact syntax for using parameters with templates can vary greatly, depending on the actual template being used. But, for an example template titled Template:Pagename, which happened to use three parameters, the general form would be:  
Line 54: Line 54:
  
 
{{shortcut|BTW:UNNAMED|BTW:POSPARAM|BTW:POSITIONAL}}
 
{{shortcut|BTW:UNNAMED|BTW:POSPARAM|BTW:POSITIONAL}}
with each parameter being substituted with a <code>value</code>, or a <code>parameter name=value</code>, when used in practice. Notice that each parameter is separated with a [[w:vertical bar|vertical bar]].  Parameters that take the form <code>value</code> are called ''unnamed'' or ''positional parameters.'' Parameters that take the form <code>parameter name=value</code> are called ''named parameters''. With unnamed parameters, the first, second, third etc. parameters are equivalent to parameters '1', '2', '3' etc. in [[BattleTechWiki:Template_documentation|template documentation.]] Unnamed parameters must be in the correct order, and best placed before named parameters. An example of the syntax using the [[Template:Collapse top]]:
+
with each parameter being substituted with a <code>value</code>, or a <code>parameter name=value</code>, when used in practice. Notice that each parameter is separated with a [[vertical bar]].  Parameters that take the form <code>value</code> are called ''unnamed'' or ''positional parameters.'' Parameters that take the form <code>parameter name=value</code> are called ''named parameters''. With unnamed parameters, the first, second, third etc. parameters are equivalent to parameters '1', '2', '3' etc. in [[BattleTechWiki:Template_documentation|template documentation.]] Unnamed parameters must be in the correct order, and best placed before named parameters. An example of the syntax using the [[Template:Collapse top]]:
  
 
<code><nowiki>{{Collapse top|This is the title text|This is a custom warning line|left=true}}</nowiki></code>
 
<code><nowiki>{{Collapse top|This is the title text|This is a custom warning line|left=true}}</nowiki></code>
Line 65: Line 65:
 
[[Help:Substitution|Substitution]] has a similar double curly-bracket syntax, and its action is similar to transclusion. When you preview a page with substitution wikitext in it, its action is identical to transclusion. But when you save a page with substitution wikitext in it, it differs in that it substitutes that wikitext with the actual wikitext of the template.  
 
[[Help:Substitution|Substitution]] has a similar double curly-bracket syntax, and its action is similar to transclusion. When you preview a page with substitution wikitext in it, its action is identical to transclusion. But when you save a page with substitution wikitext in it, it differs in that it substitutes that wikitext with the actual wikitext of the template.  
  
For example, when <code><nowiki>{{subst:Aye}}</nowiki></code> is saved, it would substitute that wikitext with the actual wikitext from the [[Template:Aye]]. In practice, the main difference that this makes is that if an update happened to the wikitext of the Template:Aye, it would not update any pages where <code><nowiki>{{subst:Aye}}</nowiki></code> had already been saved.
+
For example, when <code><nowiki>{{subst:Like}}</nowiki></code> is saved, it would substitute that wikitext with the actual wikitext from the [[Template:Like]]. In practice, the main difference that this makes is that if an update happened to the wikitext of the Template:Like, it would not update any pages where <code><nowiki>{{subst:Like}}</nowiki></code> had already been saved.
  
 
===Magic words===
 
===Magic words===
Line 73: Line 73:
  
 
===Transclusion modifiers===
 
===Transclusion modifiers===
As discussed above, with the example <code><nowiki>{{subst:Aye}}</nowiki></code>, the <code>subst:</code> code alters the transclusion to substitution. This is a ''transclusion modifier'', a type of specialist magic word for altering transclusion in some manner. Another example is <code><nowiki>{{</nowiki>:Notability<nowiki>}}</nowiki></code>, where the <code>:</code> (colon character) forces transclusion to the main namespace. There are additional transclusion modifiers such as <code>safesubst:</code>, <code>int:</code>, <code>msg:</code>, <code>msgnw:</code>, and <code>raw:</code>. For more details on their usage, see {{slink|mw:Help:Magic words#Transclusion modifiers}}. Also see the modified commands <code>#section:</code>, <code>#section-x:</code> and <code>#section-h:</code> used for [[Help:Labeled section transclusion|labeled section transclusion]].
+
As discussed above, with the example <code><nowiki>{{subst:Like}}</nowiki></code>, the <code>subst:</code> code alters the transclusion to substitution. This is a ''transclusion modifier'', a type of specialist magic word for altering transclusion in some manner. Another example is <code><nowiki>{{</nowiki>:Notability<nowiki>}}</nowiki></code>, where the <code>:</code> (colon character) forces transclusion to the main namespace. There are additional transclusion modifiers such as <code>safesubst:</code>, <code>int:</code>, <code>msg:</code>, <code>msgnw:</code>, and <code>raw:</code>. For more details on their usage, see {{slink|mw:Help:Magic words#Transclusion modifiers}}. Also see the modified commands <code>#section:</code>, <code>#section-x:</code> and <code>#section-h:</code> used for [[Help:Labeled section transclusion|labeled section transclusion]].
  
 
==Applications of transclusion==
 
==Applications of transclusion==

Please note that all contributions to BattleTechWiki are considered to be released under the GNU FDL 1.2 (see BattleTechWiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)

Advanced templates:

Editing: {{Merge}}   {{Moratorium}}   {{Otheruses| | | }}

Notices: {{NoEdit}}   {{Sign}}   {{Unsigned|name}}   {{Welcome}}

Administration: {{Essay}}   {{Policy}}   {{Procedure}}

Templates used on this page:

This page is a member of 2 hidden categories: