3,060
edits
m (Reverted edits by 165.225.104.55 (talk) (HG) (3.4.9)) |
Metriximor (talk | contribs) m (278 revisions imported from wikipedia:Help:Substitution: R to helpspace) |
||
(40 intermediate revisions by 31 users not shown) | |||
Line 1:
{{short description|Help about using templates}}
{{for|detailed guidance on when to use substitution rather than transclusion|Wikipedia:Substitution}}
{{Wikipedia how-to|H:SUBST}}
Line 8 ⟶ 9:
[[Help:variable|Variable]]s and [[Help:parser function|parser function]]s can also be substituted, meaning that their current value will be recorded permanently on the page – they will not be re-evaluated whenever someone views the page.
<ref><ref><ref></ref></ref></ref>==When to use substitution==
Generally speaking, templates are [[WP:transclusion|transcluded]] rather than substituted, although there are some that are specifically designed to be substituted (and may not work if transcluded). Some reasons for substituting templates include:
*making the resulting page independent of future changes to the template
Line 77 ⟶ 78:
[[Help:Guided tours|Guided tours]] can make posts on behalf of users, such as automatically posting the contents of a wiki page onto a talk page. Unlike normal substitution or transclusion, however, this function of guided tours does not respect {{tag|includeonly}} and similar markup. To make recursive substitution work via guided tour posting, you can use the [[m:Help:Recursive_conversion_of_wikitext#Delaying_Template:subst|Delaying Template:subst]] method described on Meta.
=== An example of recursion in action ===
{{Tlf|!}} substitutes to |.▼
This is an example using the actual [[Template:Like]], and a hypothetical Template:Foo. You are attempting to include the Template:Foo, and indirectly the Template:Like, on a third page through transclusion and substitution. Template:Like displays a like symbol like this: {{Like}}
For example, lets say the Template:Foo contained the wikitext <code><nowiki>{{Like}}</nowiki></code>. If you then transclude it, using the wikitext <code><nowiki>{{Foo}}</nowiki></code>, this will transclude the Template:Like as you would expect. But if you use the wikitext <code><nowiki>{{subst:Foo}}</nowiki></code>, when you save it you find the wikitext <code><nowiki>{{Like}}</nowiki></code> substituted rather than the wikitext of the page Template:Like. The substitution has not been recursive.
An example of recursion would be if the Template:Foo contained the wikitext <code><nowiki>{{{{{|safesubst:}}}Like}}</nowiki></code>. Now if you transclude it, using the wikitext <code><nowiki>{{Foo}}</nowiki></code>, this will transclude the Template:Like just as before. And if you save <code><nowiki>{{subst:Foo}}</nowiki></code> it will substitute the full actual wikitext of the Template:Like. You have therefore achieved recursive substitution.
=== Further examples ===
▲Note: {{Tlf|!}} substitutes to |.
{| class="wikitable"
|-
! rowspan="2" |
! rowspan="2" | When you view <nowiki>
! colspan="2" | The result of <nowiki>{{
! colspan="2" | The result of <nowiki>{{subst:
|-
! saves as:
Line 99 ⟶ 108:
||
Foo
yes
|
<nowiki>{{
||
Line 133 ⟶ 142:
<nowiki>{{subst:#if: 1 | yes | no}}</nowiki>
|
<nowiki>{{
|<nowiki>{{subst:!}}</nowiki>
Line 159 ⟶ 168:
||
Foo
yes
|
<nowiki>{{
||
Line 212 ⟶ 221:
==See also==
* [[User:Valereee/Substitution and transclusion for dummies|Substitution for Dummies]]
* [[m:Help:Substitution]], a longer and more technical help page at Meta
* [[mw:Extension:ExpandTemplates]]
Line 218 ⟶ 228:
** {{tim|last edit}} – example: <span class="plainlinks">[{{fullurl:Special:Contributions|limit=1&target={{urlencode:Example User}}}} last edit]</span>
** {{tim|page history}}
* [[Wikipedia:WikiProject Check Wikipedia#Template programming element|WikiProject Check Wikipedia § Template programming element]] lists articles where templates were substituted rather than transcluded.{{dead link|date=July 2011}} {{link note|note=According to the Wayback Machine, [//web.archive.org/web/20100528224125/http://en.wikipedia.org/wiki/Wikipedia:WikiProject_Check_Wikipedia the last time this link worked] was May 2010. It appears to have been removed since then. Perhaps [https://
{{Wikipedia template messages}}
Line 224 ⟶ 234:
{{Wikipedia technical help|collapsed}}
[[Category:Wikipedia help]]
[[Category:Wikipedia
[[fr:Aide:Modèle#Substitution]]
|