Wikipedia:Template messages/User talk namespace/Substitution

From Wikipedia, the free encyclopedia
Jump to: navigation, search

All user warning templates (in the category Category:User warning templates), as well as their shortcuts (in the category Category:Redirects from warning template), should always be substituted when warning vandals or testers. If you fail to substitute a template, a bot like User:BetacommandBot will do it for you; however, it's always best to simply do it the first time.

Workings and implications of template substitution[edit]

If you type the text {{uw-test1}} into a page and save the page, the result will look like this:

Information.svg Welcome and thank you for experimenting with Wikipedia. Your test worked, and it has been reverted or removed. Please take a look at the welcome page to learn more about contributing to this encyclopedia. If you would like to experiment further, please use the sandbox instead. Thank you.

And every single time you click "Edit this page", the text {{uw-test1}} will always be there, even though the actual text of {{uw-test1}} (shown above) may change over time. However, if you type text {{subst:uw-test1}} and click save, the result will appear the same, but checking on the page's source code, you'll see this:

{{{icon|[[Image:Information.svg|25px|left]] }}}Welcome, and thank you for experimenting with {{{{{subst|}}}#if:{{{1|}}}|the page [[:{{{1|}}}]] on}} Wikipedia. Your test worked, and it has been [[Help:Reverting|reverted]] or removed. Please take a look at the [[Wikipedia:Introduction|welcome page]] to learn more about contributing to our encyclopedia. If you would like to experiment, please use the [[Wikipedia:Sandbox|sandbox]]. {{{2|}}}<!-- Template:uw-test1 -->

By placing the text subst: in front of the template name, {{uw-test1}} was substituted. So if {{uw-test1}} changes, the display of the page on which {{uw-test1}} was substituted will not change.

See Wikipedia:Transclusion costs and benefits for a further explanation with diagrams.

Subst=subst: hack[edit]

You might notice that the text above contains a lot of complicated syntax, such as parserfunctions. There is a way to completely simplify this, and it's recommended. For the example template {{subst:uw-test1}}, the parameter {{subst:uw-test1|subst=subst:}} may also be used (in addition to providing an article name, like, {{subst:uw-test1|Kitten|subst=subst:}} which helps fellow editors identify articles for which a vandal/tester has already been warned).

What this does is simply the ParserFunctions. Saving a page with {{subst:uw-test1|Kitten}} will produce the following source code:

{{{icon|[[Image:Information.svg|25px|left]] }}}Welcome, and thank you for experimenting with {{{{{subst|}}}#if:Kitten|the page [[:Kitten]] on}} Wikipedia. Your test worked, and it has been [[Help:Reverting|reverted]] or removed. Please take a look at the [[Wikipedia:Introduction|welcome page]] to learn more about contributing to our encyclopedia. If you would like to experiment, please use the [[Wikipedia:Sandbox|sandbox]]. {{{2|}}}<!-- Template:uw-test1 -->

Saving a page with {{subst:uw-test1|Kitten|subst=subst:}}, however, will yield

{{{icon|[[Image:Information.svg|25px|left]] }}}Welcome, and thank you for experimenting with the page [[:Kitten]] on Wikipedia. Your test worked, and it has been [[Help:Reverting|reverted]] or removed. Please take a look at the [[Wikipedia:Introduction|welcome page]] to learn more about contributing to our encyclopedia. If you would like to experiment, please use the [[Wikipedia:Sandbox|sandbox]]. {{{2|}}}<!-- Template:uw-test1 -->

This has to do with ParserFunction substitution transclusion (see explanation)