Help:Transclusion: Difference between revisions
Orangestar (talk | contribs) m Text replacement - "[[WP:" to "[[wikipedia:WP:" |
Orangestar (talk | contribs) m Text replacement - "Help:Substitution" to "wikipedia:Help:Substitution" |
||
Line 56: | Line 56: | ||
{{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 <syntaxhighlight lang="wikitext" inline>{{Pagename}}</syntaxhighlight>. 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 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 [[wikipedia:Help:Substitution|substitution]]. As shown above, the usual syntax for transcluding a template titled Template:Pagename is <syntaxhighlight lang="wikitext" inline>{{Pagename}}</syntaxhighlight>. 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 72: | Line 72: | ||
===Substitution=== | ===Substitution=== | ||
[[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. | [[wikipedia: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 <syntaxhighlight lang="wikitext" inline>{{subst:Like}}</syntaxhighlight> 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 <syntaxhighlight lang="wikitext" inline>{{subst:Like}}</syntaxhighlight> had already been saved. | For example, when <syntaxhighlight lang="wikitext" inline>{{subst:Like}}</syntaxhighlight> 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 <syntaxhighlight lang="wikitext" inline>{{subst:Like}}</syntaxhighlight> had already been saved. |