Module:Unsubst/doc: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
cleanup some markup
m (+ note for infoboxes)
(cleanup some markup)
Line 1:
<!-- Categories where indicated at the bottom of this page, please. -->
 
{{High-risk|2,200,000+}}
{{Module rating|protected}}
Line 14 ⟶ 13:
To turn a template into a self-substituting template, wrap the existing template code with:
<pre>
{{ {{{|safesubstSAFESUBST:}}}<noinclude />#invoke:Unsubst||$B=
 
[ ... existing template code ... ]
Line 23 ⟶ 22:
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 "__DATE__", that value in the generated template invocation will be the current month and year.
 
Some templates have a &lt;{{tag|noinclude&gt;|o}} but no matching &lt;/{{tag|noinclude&gt;|c}} at the end of the template. In such cases the missing &lt;/{{tag|noinclude&gt;|c}} must be added before the ending <code>{{))}}</code>.
 
==== Advanced ====
 
<pre>
{{ {{{|safesubstSAFESUBST:}}}<noinclude />#invoke:Unsubst||$params=[ parameters ]|$aliases=[ aliases ]|$flags=[ flags ]|$B=
 
[ ... existing template code ... ]
Line 41 ⟶ 40:
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>{{(((}}{{!}}safesubst<nowiki>SAFESUBST:{{)))}}<noinclude /></nowiki></code>).
 
=== Example ===
Consider a template Template:Example containing the following code:
<pre>
{{ {{{|safesubstSAFESUBST:}}}<noinclude />#invoke:Unsubst||foo=bar |date=__DATE__ |$B=
 
[ ... Template code goes here ... ]
Line 56 ⟶ 55:
! Original !! Result
|-
| <nowiki>{{subst:tlsc|example}}</nowiki> || <nowiki>{{tlc|Example|foo=bar|date{{=</nowiki>}}{{#time:F Y}}}}
|-
| <nowiki>{{subst:tlsc|example|foo{{=}}X}}</nowiki> || <nowiki>{{tlc|Example|foo{{=}}X|date{{=</nowiki>}}{{#time:F Y}}}}
|-
| <nowiki>{{subst:tlsc|example|baz{{=}}X}}</nowiki> || <nowiki>{{tlc|Example|foo=bar|baz{{=}}X|date{{=</nowiki>}}{{#time:F Y}}}}
|-
| <nowiki>{{subst:tlsc|example|date{{=}}January 2001}}</nowiki> || <nowiki>{{tlc|Example|foo{{=}}bar|date{{=}}January 2001}}</nowiki>
|}
 
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox other||
| <!-- Categories below this line, please; interwikis at Wikidata -->
[[Category:Wikipedia metatemplates]]
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu