JohnnyB256 (talk | contribs) m Reverted edits by 78.160.52.70 to last revision by Iceblock (HG) |
*/Transclusion markup/* copyedit: introduce the concept of "rendering", simplify the language, add the idea of "invisible ink", include wikilinks to "comments" and "tags". |
||
Line 17: | Line 17: | ||
===Transclusion markup=== |
===Transclusion markup=== |
||
There are three [[html#elements|tags]], named ''noinclude'', ''includeonly'', and ''onlyinclude''. |
|||
They all affect whether or not wikitext renders, either in an article or in a transclusion. |
|||
* '''noinclude'''. The markup <nowiki><noinclude>...</noinclude></nowiki> means that the text between the tags will not be transcluded onto another page, but will only appear on the page itself. This is useful for documentation. |
|||
* ''' |
* '''noinclude'''. The markup <nowiki><noinclude>...</noinclude></nowiki> means that the text between the tags will not be rendered at all: neither in the article nor in any transclusion. ''Noinclude'' tags are acceptable for [[Help:comment tags|wikitext comments]]. |
||
* '''includeonly'''. The markup <nowiki><includeonly>...</includeonly></nowiki> means that the text between the tags will not render in the article, but will render if transcluded. It is like invisible ink, activated by transclusion magic. This can be useful, for example, for adding categories to pages transcluding a template, without adding the template itself to these categories. |
|||
* '''onlyinclude'''. The markup <nowiki><onlyinclude>...</onlyinclude></nowiki> indicates that only text surrounded by "onlyinclude" markup should be transcluded onto another page. This is the most subtle of the partial transclusion tags because it often overrules the others. If there is at least one pair of "onlyinclude" tags on a page, then whenever this page is transcluded, it is ''only'' the material within the "onlyinclude" tags which gets transcluded. There can be several such sections, and within each such section, some material might be further excluded by "noinclude" tags, and might also be surrounded by "includeonly" tags so that it does not appear on the original page itself. But material outside the "onlyinclude" tags will be ignored when the page is transcluded onto another page. This can be useful, for example, to repeat a small part of one page on a second one: just surround the small part by onlyinclude tags, and transclude it onto the second page. |
|||
* '''onlyinclude'''. The markup <nowiki><onlyinclude>...</onlyinclude></nowiki> means that the text between the tags will render in the article and will render in the transclusion. The rest of the wikitext, outside these tags is not transcluded. There can be several such sections. This can be useful, for example, to repeat a small part of one page on a second one: just surround the small part by onlyinclude tags, and transclude it onto the second page. |
|||
The behavior of each of these tags are consistently observed when the tags are nested. |
|||
===Subpages=== |
===Subpages=== |
Revision as of 23:12, 1 December 2009
Transclusion is the inclusion of the content of a document into another document by reference. In the Wikipedian context, it is the use of the template functionality of MediaWiki to include the same content in multiple documents without having to edit those documents separately. Template transclusion is the common way to use template messages, and is implemented by using a template tag, with this form:
{{template name}}
Occasionally one may want to use a template, but for one reason or another may not want to use transclusion. The automatic one-time copying of a template's code/text to the location of a template tag is called Template substitution or subclusion (substitution + transclusion). To subclude a template's code/text, the template tag is modified from the standard transclusion tag to a substitution tag, simply by adding subst:
, creating a tag with the form: {{subst:Template name}}
.
To transclude any source page (within a single MediaWiki project, such as en:Wikipedia), use the following code in the target page:
{{SOURCEPAGE}}
Any time you write the code ({{SOURCEPAGE}}
) in a target page, you are telling Wikipedia software to put the entire content of SOURCEPAGE
in the target page.
In the example below, look at target page A and SOURCEPAGE
B.
If B is transcluded in A, Wikipedia software will include in that specific place not the code ({{B}}
) itself but the content of source page B (which is just the word foo).
The top row shows how target pages A, P, and Q will look with the changes in code seen in the bottom row to transclude source page B. Note the position of the code in each example target page.
The source page content, foo, will not be highlighted or boxed on the target page. (Foo is in a light blue box here for ease of illustration and understanding.)
Transclusion creates a "live" link between a source page and the target page(s) where the source page's contents appear. This means that when you edit a source page, you will be updating its content across all the target pages that include it. Let's say you create a source page in Wikipedia with the address, date, and time of a local Wikimedia event that you want to invite 50 local editors to. Next, you transclude the invitation source page onto your talk page as well as the talk pages of the other 50 editors. A week later you discover the place for the event must be moved. You would then update the source page, and the new address will automatically appear on all the other attendees' talk pages. You could also tell the editors to invite people you may have missed. They could then simply transclude the invitation source page into other editors' talk pages themselves.
Remember to be extremely careful about editing any source page, especially if it contains transclusions from other source pages. Breaking existing transclusions in a source page is called breakage. Please avoid breakage(s) because not only the larger source page you are editing and all the target pages that include it will be affected. So will both the already embedded (now broken) source page that was used to add content to the larger source page, as well as every target page where the embedded source page was transcluded.
Etymology
Ted Nelson coined the term "transclusion," as well as "hypertext" and "hypermedia", in his 1982 book, Literary Machines.
Partial transclusion
By using "noinclude", "onlyinclude" and "includeonly" markup, it is possible to transclude part of a page rather than all of it. Such partial transclusions can also be achieved by transcluding from other pages such as subpages. It is often useful not to transclude some information, such as template documentation.
For an example of how this technique can be applied to simplify the creation of summary articles, see Pathology, which consists of a collection of transcluded lead paragraphs from several main articles.
Transclusion markup
There are three tags, named noinclude, includeonly, and onlyinclude. They all affect whether or not wikitext renders, either in an article or in a transclusion.
- noinclude. The markup <noinclude>...</noinclude> means that the text between the tags will not be rendered at all: neither in the article nor in any transclusion. Noinclude tags are acceptable for wikitext comments.
- includeonly. The markup <includeonly>...</includeonly> means that the text between the tags will not render in the article, but will render if transcluded. It is like invisible ink, activated by transclusion magic. This can be useful, for example, for adding categories to pages transcluding a template, without adding the template itself to these categories.
- onlyinclude. The markup <onlyinclude>...</onlyinclude> means that the text between the tags will render in the article and will render in the transclusion. The rest of the wikitext, outside these tags is not transcluded. There can be several such sections. This can be useful, for example, to repeat a small part of one page on a second one: just surround the small part by onlyinclude tags, and transclude it onto the second page.
The behavior of each of these tags are consistently observed when the tags are nested.
Subpages
One can cut and paste the text to be transcluded into a subpage, then use the name of the subpage in the transclusion template. This approach can only be used with subpages from User, Talk or Wikipedia pages; currently, subpages cannot be created from main article pages.
Example: you want to discuss the deletion and redirecting of Pussycat to Cat. First, create the subpage Talk:Pussycat/Let's delete Pussycat!, write your comment into it, then transclude it in Talk:Pussycat and Talk:Cat using the template {{Talk:Pussycat/Let's delete Pussycat!}}. Comments posted in either talk pages will be shown in both.
Special pages
Some pages on Special:Specialpages can be transcluded, such as Special:Allpages, Special:Prefixindex, Special:Newfiles, Special:Newpages, Special:Recentchanges and Special:Recentchangeslinked.
Samples:
- {{Special:Allpages/General}} – a list of pages starting at "General"
- {{Special:Prefixindex/General}} – a list of pages with prefix "General"
- {{Special:Newfiles/4}} – a gallery of the four most recently uploaded files
- {{Special:Newpages/5}} – a list of the five most recently created pages
- {{Special:Recentchanges/5}} – the five most recent changes
- {{Special:Recentchangeslinked/General}} – recent changes to the pages linked from "General"
Except for Special:Recentchangeslinked, the slash and the word/number after the slash can be omitted, giving a list of pages without a specific starting point, or a list of the default length.
Templates
See also
- Request for template transclusion from Commons (interwiki templates, etc.)
- Wikipedia:Substitution (the opposite of transclusion)