Module:Unsubst/doc: Difference between revisions

m 1 revision imported
m 1 revision imported
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
<!-- Categories where indicated at the bottom of this page, please. -->
<!-- Categories where indicated at the bottom of this page, please. -->
{{High-risk| 3841439 |all-pages = yes}}
{{high-risk|all=pages=yes}}
{{Module rating|protected}}
{{Module rating|protected}}
{{lua|Module:Template invocation|noprotcat=yes}}


This is a helper module to facilitate a substituted template transform into a template transclusion.
Maintenance templates, such as {{tl|Citation needed}} or {{tl|Refimprove}}, should never be substituted. A trick to avoid that is to make a template substitute to its transcluded form. This module implements that trick.
 
Maintenance templates, such as {{tl|Citation needed}} or {{tl|Refimprove}}, should never be substituted. A trick to avoid that is to make a template substitute to its transcluded form.


Infoboxes should use [[Module:Unsubst-infobox]], as should any other templates with parameters listed in block format by default.
Infoboxes should use [[Module:Unsubst-infobox]], as should any other templates with parameters listed in block format by default.


=== Usage ===
=== Usage ===
To turn a template into a self-substituting template, wrap the existing template code with:
To turn a template into a self-substituting template, wrap the existing template code with:
<pre>
<pre>
{{SAFESUBST:<noinclude />#invoke:Unsubst||$B=
{{safesubst:<noinclude />#invoke: Unsubst||$B=


  [ ... existing template code ... ]
  [ ... existing template code ... ]
Line 27: Line 25:


<pre>
<pre>
{{SAFESUBST:<noinclude />#invoke:Unsubst||$params=[ parameters ]|$aliases=[ aliases ]|$flags=[ flags ]|$B=
{{safesubst:<noinclude />#invoke: Unsubst||$params=[ parameters ]|$aliases=[ aliases ]|$flags=[ flags ]|$B=


  [ ... existing template code ... ]
  [ ... existing template code ... ]
Line 42: Line 40:
These parameters can be manipulated using parser functions to provide more complicated options (note that in the parameters any parser function, or template or module invocation, should also have <code><nowiki>SAFESUBST:<noinclude /></nowiki></code>).
These parameters can be manipulated using parser functions to provide more complicated options (note that in the parameters any parser function, or template or module invocation, should also have <code><nowiki>SAFESUBST:<noinclude /></nowiki></code>).


Parameter {{para|$template-name}} will override the subst'd templates name with the template name assigned to this parameter.
Parameter {{para|$template-name}} will override the subst'd template's name with the template name assigned to this parameter.


=== Example ===
=== Example ===
Consider a template Template:Example containing the following code:
Consider a template Template:Example containing the following code:
<pre>
<pre>
{{SAFESUBST:<noinclude />#invoke:Unsubst||foo=bar |date=__DATE__ |$B=
{{safesubst:<noinclude />#invoke: Unsubst||foo=bar |date=__DATE__ |$B=


  [ ... Template code goes here ... ]
  [ ... Template code goes here ... ]
Line 55: Line 53:


{| class="wikitable"
{| class="wikitable"
|-
! Original !! Result
! Original !! Result
|-
|-
| {{tlsc|example}} || {{tlc|Example|foo=bar|date{{=}}{{#time:F Y}}}}
| {{tlsc|example}} || {{tlc|Example|date{{=}}{{#time:F Y}}|foo{{=}}bar}}
|-
|-
| {{tlsc|example|foo{{=}}X}} || {{tlc|Example|foo{{=}}X|date{{=}}{{#time:F Y}}}}
| {{tlsc|example|foo{{=}}X}} || {{tlc|Example|date{{=}}{{#time:F Y}}|foo{{=}}X}}
|-
|-
| {{tlsc|example|baz{{=}}X}} || {{tlc|Example|foo=bar|baz{{=}}X|date{{=}}{{#time:F Y}}}}
| {{tlsc|example|baz{{=}}X}} || {{tlc|Example|baz{{=}}X|date{{=}}{{#time:F Y}}|foo{{=}}bar}}
|-
|-
| {{tlsc|example|date{{=}}January 2001}} || {{tlc|Example|foo{{=}}bar|date{{=}}January 2001}}
| {{tlsc|example|date{{=}}January 2001}} || {{tlc|Example|date{{=}}January 2001|foo{{=}}bar}}
|}
|}