Help page: Edit

Editing Help:Substitution

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 37: Line 37:
  
 
==Technical implementation==
 
==Technical implementation==
Substitution is part of the process performed on saving a page, and causes the wikitext saved as a result of the edit to differ from the text which the user actually entered in the edit window. Other replacements performed during this process include expansion of links using the [[w:Help:Pipe trick|pipe trick]], and replacement of multiple tildes with signatures and timestamps.
+
Substitution is part of the process performed on saving a page, and causes the wikitext saved as a result of the edit to differ from the text which the user actually entered in the edit window. Other replacements performed during this process include expansion of links using the [[BTW:pipe trick|pipe trick]], and replacement of multiple tildes with signatures and timestamps.
  
 
This means that substitution necessarily occurs before any actions performed at the time of page rendering (conversion of the stored wikitext to HTML). In particular, ''substitutions are done before transclusions''. So typing <code><nowiki>{{subst:Help:L{{in(tut)}}k}}</nowiki></code> will not do substitution, even though {{tl|in(tut)}} returns the text "in" and [[Help:Link]] exists. The transclusion of {{tl|in(tut)}} has not yet taken place when the substitution is attempted. However, replace <code><nowiki>{{in(tut)}}</nowiki></code> with <code><nowiki>{{subst:in(tut)}}</nowiki></code>, and both substitutions will be performed in the expected order.
 
This means that substitution necessarily occurs before any actions performed at the time of page rendering (conversion of the stored wikitext to HTML). In particular, ''substitutions are done before transclusions''. So typing <code><nowiki>{{subst:Help:L{{in(tut)}}k}}</nowiki></code> will not do substitution, even though {{tl|in(tut)}} returns the text "in" and [[Help:Link]] exists. The transclusion of {{tl|in(tut)}} has not yet taken place when the substitution is attempted. However, replace <code><nowiki>{{in(tut)}}</nowiki></code> with <code><nowiki>{{subst:in(tut)}}</nowiki></code>, and both substitutions will be performed in the expected order.
Line 44: Line 44:
 
*Typing <code><nowiki>{{subst:#if:{{x0}}|yes|no}}</nowiki></code> gives the wikitext "yes", even though {{tl|x0}} is an empty template, since the conditional parameter evaluates to the non-empty string "<nowiki>{{x0}}</nowiki>". However <code><nowiki>{{subst:#if:{{subst:x0}}|yes|no}}</nowiki></code> produces "no", since the inner substitution is performed first.
 
*Typing <code><nowiki>{{subst:#if:{{x0}}|yes|no}}</nowiki></code> gives the wikitext "yes", even though {{tl|x0}} is an empty template, since the conditional parameter evaluates to the non-empty string "<nowiki>{{x0}}</nowiki>". However <code><nowiki>{{subst:#if:{{subst:x0}}|yes|no}}</nowiki></code> produces "no", since the inner substitution is performed first.
 
*Typing <code><nowiki>{{subst:#expr:2*{{{p|3}}}}}</nowiki></code> returns ''Expression error: unrecognised punctuation character "{"'', as the undefined parameter <nowiki>{{{p}}}</nowiki> has not been replaced by its default value (3) when the substitution occurs.
 
*Typing <code><nowiki>{{subst:#expr:2*{{{p|3}}}}}</nowiki></code> returns ''Expression error: unrecognised punctuation character "{"'', as the undefined parameter <nowiki>{{{p}}}</nowiki> has not been replaced by its default value (3) when the substitution occurs.
 
+
*If {{tl|t6}} contains the text "t2|a", then <code><nowiki>{{ {{subst:t6}} }}</nowiki></code> will produce the wikitext "<nowiki>{{ t2|a }}</nowiki>", rendered as "{{t2|a}}" Contrast this with the behaviour of <code><nowiki>{{ {{t6}} }}</nowiki></code>, which is rendered as "{{ {{t6}} }}", because the parser does not reinterpret the pipe as a separator during the non-substituted expansion stage. (Similarly, <code><nowiki>{{subst:{{subst:t6}} }}</nowiki></code> gives the wikitext <code><nowiki>{{subst:t2|a }}</nowiki></code>, which only on the next edit will be substituted with {{t2|a}}.)
  
 
Clicking the "Show changes" button during editing shows the wikitext that will result ''after'' substitution and other immediate replacements are carried out. Clicking "Show preview" shows what the rendered page will look like after these replacements.
 
Clicking the "Show changes" button during editing shows the wikitext that will result ''after'' substitution and other immediate replacements are carried out. Clicking "Show preview" shows what the rendered page will look like after these replacements.

Please note that all contributions to BattleTechWiki are considered to be released under the GNU FDL 1.2 (see BattleTechWiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)

Advanced templates:

Editing: {{Merge}}   {{Moratorium}}   {{Otheruses| | | }}

Notices: {{NoEdit}}   {{Sign}}   {{Unsigned|name}}   {{Welcome}}

Administration: {{Essay}}   {{Policy}}   {{Procedure}}

Templates used on this page:

This page is a member of 2 hidden categories: