Content deleted Content added
m + note for infoboxes |
Reverted 1 edit by 2804:29B8:5161:2E33:BD3A:7743:CD0:AF9C (talk): Unexplained blanking |
||
(37 intermediate revisions by 26 users not shown) | |||
Line 1:
<!-- Categories where indicated at the bottom of this page, please. -->
{{high-risk|all=pages=yes}}
{{Module rating|protected}}
{{lua|Module:Template invocation|noprotcat=yes}}
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.
=== Usage ===
To turn a template into a self-substituting template, wrap the existing template code with:
<pre>
{{
[ ... existing template code ... ]
Line 21 ⟶ 18:
</pre>
The wikitext to display when not substed must be given as "$B". All other parameters passed to the #invoke will be copied to the generated template invocation as default values. If the value of any of these default parameters is
Some templates have a
==== Advanced ====
<pre>
{{
[ ... existing template code ... ]
Line 41 ⟶ 38:
Parameter {{para|$flags}} can be used to modify other facets of the module's behaviour; entries are comma-separated. Valid flags are <code>override</code> (allows parameters in the #invoke: to take precedence over parameters in the original template invocation); <code>keep-whitespace</code> (prevents whitespace from being trimmed from unnamed parameters); and <code>remove-empty</code> (removes empty parameters).
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>
Parameter {{para|$template-name}} will override the subst'd template's name with the template name assigned to this parameter.
=== Example ===
Consider a template Template:Example containing the following code:
<pre>
{{
[ ... Template code goes here ... ]
Line 54 ⟶ 53:
{| class="wikitable"
|-
! Original !! Result
|-
|
|-
|
|-
|
|-
|
|}
<includeonly>{{
| <!-- Categories below this line, please; interwikis at Wikidata -->
[[Category:Wikipedia metatemplates]]
|