Help:Transclusion/How Transclusion Works: Difference between revisions

Content deleted Content added
expanded content to be less verbose in order to improve clarity
Tag: Reverted
grammar; changed example, as we don't typically share editor street addresses on WP, especially not en masse. Replaced with something uncomplicated but still in context of WP
Tag: Reverted
Line 6:
Whenever a target page with this code (<code><nowiki>{{SOURCEPAGE}}</nowiki></code>) is rendered, the engine will include the entire content of <code><nowiki>SOURCEPAGE</nowiki></code> in the target page.
 
In the example below, let the target page be '''A''' and <code><nowiki>SOURCEPAGE</nowiki></code> be '''B'''. If <code><nowiki>{{B}}</nowiki></code> is rendered, the engine will include ''in that place'' not the code (<code><nowiki>{{B}}</nowiki></code>) itself but the content of source page '''B''' (which consists of one word, foo).
 
If <code><nowiki>{{B}}</nowiki></code> is rendered, then the engine will include ''in that place'' not the code (<code><nowiki>{{B}}</nowiki></code>) itself but the content of source page '''B''' (which in this example, consists of only one word, foo).
The top row shows what the target page renders as, while the bottom row shows the code. Note: foo will not be highlighted nor boxed on the target page.
 
The top row shows whathow the target page renders as, while the bottom row shows the code required to transclude the source page within the target page. Note: that foo will not be highlighted nor boxed on the target page.
 
<div style="margipadding: 0.5em;">[[File:Transclusion-multiple-foo.svg]]</div>
Line 14 ⟶ 16:
A typical use case for transclusion would be if you wanted to place the same welcome message on multiple newcomer talk pages.
 
Transclusion creates a "live" link between the template page and the target page(s) upon which the template's contents should appear. When the template is edited, the rendering of that template on the target pages is updated as well. Let's say you create a (template) page in Wikipedia with yourthe homeaddress mailingof addressa andlocal thenWikimedia event. Next, you transclude that template not only on your talk page, butand allalso youron friends'the talk pages, tooof all local editors to be invited. LaterA week later, afterthe movingevent is moved to a newslightly house,larger youplace. You would then update yourthe address template, and the ''newrevised'' address will automatically appear on all yourthe other friendsattendees' pages.
 
There are further simple examples at [[mw:Transclusion]].
 
Breaking existing transclusions in a template is called '''breakage'''. It is to be avoided if possible, as the breakagebreak will ripplepropagate through every target page in which the template (source) page was transcluded.