WP:SAFESUBST
From Iwe
(Created page with '==={{anchor|safesubst}}The safesubst: modifier=== {{shortcut|WP:SAFESUBST}} The <code>subst:</code> modifier can be replaced by the alternative modifier <code>safesubst:</code>. …') |
|||
Line 1: | Line 1: | ||
- | |||
- | |||
The <code>subst:</code> modifier can be replaced by the alternative modifier <code>safesubst:</code>. The two have the same behaviour, except when they are encountered during non-substituted expansion (transclusion or direct viewing) of a template. In this situation, the code <code><nowiki>{{subst:...}}</nowiki></code> remains unparsed, whereas <code><nowiki>{{safesubst:...}}</nowiki></code> is treated as if no modifier were present (so the subtemplate is transcluded or the variable or parser function evaluated). | The <code>subst:</code> modifier can be replaced by the alternative modifier <code>safesubst:</code>. The two have the same behaviour, except when they are encountered during non-substituted expansion (transclusion or direct viewing) of a template. In this situation, the code <code><nowiki>{{subst:...}}</nowiki></code> remains unparsed, whereas <code><nowiki>{{safesubst:...}}</nowiki></code> is treated as if no modifier were present (so the subtemplate is transcluded or the variable or parser function evaluated). | ||
Hence the <code>safesubst:</code> modifier is used in the code of templates which are designed to produce recursive substitution when substituted, but are also intended to work when transcluded – or simply to be viewed directly. Using plain <code>subst:</code> in such templates would break in the case of transclusion (and possibly on direct viewing). For details on how to implement this (in particular, how to prevent the substitution from being performed as soon as the template code is saved), see the next section, [[#Recursive substitution|''Recursive substitution'']]. | Hence the <code>safesubst:</code> modifier is used in the code of templates which are designed to produce recursive substitution when substituted, but are also intended to work when transcluded – or simply to be viewed directly. Using plain <code>subst:</code> in such templates would break in the case of transclusion (and possibly on direct viewing). For details on how to implement this (in particular, how to prevent the substitution from being performed as soon as the template code is saved), see the next section, [[#Recursive substitution|''Recursive substitution'']]. |
Revision as of 23:11, 8 September 2014
The subst:
modifier can be replaced by the alternative modifier safesubst:
. The two have the same behaviour, except when they are encountered during non-substituted expansion (transclusion or direct viewing) of a template. In this situation, the code {{subst:...}}
remains unparsed, whereas {{safesubst:...}}
is treated as if no modifier were present (so the subtemplate is transcluded or the variable or parser function evaluated).
Hence the safesubst:
modifier is used in the code of templates which are designed to produce recursive substitution when substituted, but are also intended to work when transcluded – or simply to be viewed directly. Using plain subst:
in such templates would break in the case of transclusion (and possibly on direct viewing). For details on how to implement this (in particular, how to prevent the substitution from being performed as soon as the template code is saved), see the next section, Recursive substitution.