*/Transclusion markup/* copyedit: introduce the concept of "rendering", simplify the language, add the idea of "invisible ink", include wikilinks to "comments" and "tags". |
→Transclusion markup: Finish the copyedit. |
||
Line 18: | Line 18: | ||
===Transclusion markup=== |
===Transclusion markup=== |
||
There are three [[html#elements|tags]], named ''noinclude'', ''includeonly'', and ''onlyinclude''. |
There are three [[html#elements|tags]], named ''noinclude'', ''includeonly'', and ''onlyinclude''. |
||
They all |
They all determine whether or not wikitext renders, either in it's own article or in another article where it is transcluded. |
||
* '''noinclude'''. The markup <nowiki><noinclude>...</noinclude></nowiki> means that the text between the tags will |
* '''noinclude'''. The markup <nowiki><noinclude>...</noinclude></nowiki> means that the text between the tags will be rendered '''not at all''': neither in the article nor in any transclusion. ''Noinclude'' tags are acceptable for [[Help:comment tags|wikitext comments]]. There can be several such sections. |
||
* '''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. |
* '''includeonly'''. The markup <nowiki><includeonly>...</includeonly></nowiki> means that the text between the tags will not render in the article, but will only render '''if transcluded'''. These tags ''have an effect on their own article'' where it is as if the section is made of invisible ink, activated by transclusion magic. There can be several such sections. This can be useful, for transclusion commentary and for adding a category to a page transcluding a template, without adding the template itself to that category. |
||
* '''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. |
* '''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. These tags ''have no effect on it's own article'', but when the wikitext is transcluded '''only what is inside the tags''' is rendered there. 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. |
The behavior of each of these tags are consistently observed when the tags are nested. A section rendered with either of the later two tags may make further rendering omissions with the first tag, or the ''onlyinclude'' tag may nest ''includeonly'', etc. All possible transclusion needs are met with these three tags. |
||
===Subpages=== |
===Subpages=== |
Revision as of 23:45, 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 determine whether or not wikitext renders, either in it's own article or in another article where it is transcluded.
- noinclude. The markup <noinclude>...</noinclude> means that the text between the tags will be rendered not at all: neither in the article nor in any transclusion. Noinclude tags are acceptable for wikitext comments. There can be several such sections.
- includeonly. The markup <includeonly>...</includeonly> means that the text between the tags will not render in the article, but will only render if transcluded. These tags have an effect on their own article where it is as if the section is made of invisible ink, activated by transclusion magic. There can be several such sections. This can be useful, for transclusion commentary and for adding a category to a page transcluding a template, without adding the template itself to that category.
- onlyinclude. The markup <onlyinclude>...</onlyinclude> means that the text between the tags will render in the article and will render in the transclusion. These tags have no effect on it's own article, but when the wikitext is transcluded only what is inside the tags is rendered there. 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. A section rendered with either of the later two tags may make further rendering omissions with the first tag, or the onlyinclude tag may nest includeonly, etc. All possible transclusion needs are met with these three tags.
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)