Help:Transclusion

From Leftypedia
Jump to navigation Jump to search

Transclusion means the inclusion of the content of one document within another document by reference. In Leftypedia transclusion, the MediaWiki software will refer to the content of one page, the template, for inclusion into the content of any other page, the target page. Similar to the way any page name can become a link by placing its name in double square brackets, any page name can become a template by placing it in double curly braces, {{Namespace:Pagename}}. Changes made to the template are then automatically reflected on all pages into which that page has been transcluded (though a purge may sometimes be necessary).

If the template's page name does not begin with a namespace, it is assumed to be in the Template namespace. To refer to a page in the "Main" (article) namespace, it is necessary to prefix it with a colon (:). Examples:

What will transclude from a page can be controlled with the tags <noinclude>, <onlyinclude> and <includeonly> placed in the source page wikitext. (See markup, below.) The use of tags enables the template to transclude partially, otherwise the double curly braces will always transclude all content. For selective transclusion the <includeonly> parts of the template are named (with the help of parser functions) and that template is then called with the parameter transcludesection=name.

Target page syntax

Basic use

To transclude a page, include both the namespace and the page name (separated with a colon) within the double-brace:

{{Help:Transclusion}}

When transcluding a [[<tvar name=1>Special:MyLanguage/Help:Templates</tvar>|template]], you may omit the namespace and colon:

{{infobox}}

When transcluding an article in the Main namespace, you may omit the namespace:

{{:Transclusion}}

When transcluding a subpage of the target page, you may use the subpage name by itself:

{{/doc}}

Parameters

Transcluded templates and <tvar name=1>Template:Ll</tvar> may accept parameters:

{{note|inline|This is a note.}}

Source page syntax

Three tags (<tvar name=1><noinclude></tvar>, <tvar name=2><includeonly></tvar>, and <tvar name=3><onlyinclude></tvar>) control which content appears in the target page.

<noinclude>
Content within the <tvar name=1><noinclude>...</noinclude></tvar> tags is excluded from transclusion on the target page. This content still appears on the source page.
Source page wikitext</translate> What appears on the source page</translate> What appears on the target page</translate>
Hello <noinclude>world</noinclude> Hello world Hello
<includeonly>
Content within the <tvar name=1><includeonly>...</includeonly></tvar> tags is transcluded on the target page, but does not appear on the source page.
<translate> Source page wikitext</translate> <translate> What appears on the source page</translate> <translate> What appears on the target page</translate>
Hello <includeonly>world</includeonly> Hello Hello world
<onlyinclude>
Content within the <tvar name=1><onlyinclude>...</onlyinclude></tvar> tags is transcluded on the target page, and also appears on the source page.
Source page wikitext What appears on the source page What appears on the target page
Hello <onlyinclude>world</onlyinclude> Hello world world

See also