Difference between revisions of "Template:Xpd/doc"

From AerialWiki
Jump to navigation Jump to search
(Created page with "<noinclude><div class="messagebox" id="template_doc_page_viewed_directly" style="text-align: center"> This subpage contains [[w:Wikipedia:Template documentation|documentation]...")
 
 
(3 intermediate revisions by the same user not shown)
Line 6: Line 6:
 
-->
 
-->
  
This {{til|xpd}} (expansion demo) shows the call of a variable, parser function or template and its result, for documentation.
+
This <nowiki>{{xpd}}</nowiki> (expansion demo) shows the call of a variable, parser function or template and its result, for documentation.
  
 
;Usage&#58;
 
;Usage&#58;
 
:{{Tlx|xpd|left side|</tt>up to 3 additional parameters}}
 
:{{Tlx|xpd|left side|</tt>up to 3 additional parameters}}
  
Please note that for [[m:Help:Parser function|parser functions]] the first parameter belongs to the left side before "|".
+
Please note that for [[mw:Help:Parser function|parser functions]] the first parameter belongs to the left side before "|".
  
 
Examples without additional parameters:
 
Examples without additional parameters:
Line 33: Line 33:
 
{&#123;subst:xpd|uc:Upper Case|subst=subst:&#125;} substitutes {&#123;<small>&#160;</small><code>subst:uc:Upper Case</code>&#125;} {{{2|gives}}} UPPER CASE
 
{&#123;subst:xpd|uc:Upper Case|subst=subst:&#125;} substitutes {&#123;<small>&#160;</small><code>subst:uc:Upper Case</code>&#125;} {{{2|gives}}} UPPER CASE
  
See [[m:Help:Substitution|Help:Substitution]] for several caveats wrt <tt>subst=subst:</tt>.
+
See [[mw:Help:Substitution|Help:Substitution]] for several caveats wrt <tt>subst=subst:</tt>.
  
 
Note that, as always, a parameter containing "=" has to be explicitly named by putting, in this case, "1=" in front.
 
Note that, as always, a parameter containing "=" has to be explicitly named by putting, in this case, "1=" in front.
  
{{til|Xpdn}} can be used in the case of an expression in double braces which itself includes a pair of double braces (simple '''nested''' expressions). Use "|" for the inner "<nowiki>{{</nowiki>" and, if there is code after it, also for "}}".
+
<nowiki>{{Xpdn}}</nowiki> can be used in the case of an expression in double braces which itself includes a pair of double braces (simple '''nested''' expressions). Use "|" for the inner "<nowiki>{{</nowiki>" and, if there is code after it, also for "}}".
  
 
{| class="wikitable"
 
{| class="wikitable"

Latest revision as of 21:17, 6 September 2012

This subpage contains documentation, categories and other content that is not part of the template.
To view the template page itself, see Template:Xpd.

This {{xpd}} (expansion demo) shows the call of a variable, parser function or template and its result, for documentation.

Usage:
{{xpd|left side|up to 3 additional parameters}}

Please note that for parser functions the first parameter belongs to the left side before "|".

Examples without additional parameters:

{{xpd|tc}} {{tc}} gives in
{{xpd|CURRENTDAY}} {{CURRENTDAY}} gives 22
{{xpd|#expr:2*3}} {{#expr:2*3}} gives 6
{{xpd|1=#expr:2+2=5}} {{#expr:2+2=5}} gives 0
{{xpd|1=#expr:2+2=4}} {{#expr:2+2=4}} gives 1
{{xpd|urlencode:!}} {{urlencode:!}} gives %21
{{xpd|uc:abc}} {{uc:abc}} gives ABC

{{subst:xpd|uc:Upper Case|subst=subst:}} substitutes {{ subst:uc:Upper Case}} gives UPPER CASE

See Help:Substitution for several caveats wrt subst=subst:.

Note that, as always, a parameter containing "=" has to be explicitly named by putting, in this case, "1=" in front.

{{Xpdn}} can be used in the case of an expression in double braces which itself includes a pair of double braces (simple nested expressions). Use "|" for the inner "{{" and, if there is code after it, also for "}}".

{{xpdn|#expr:24*|CURRENTDAY}} {{#expr:24*{{CURRENTDAY}}}} gives 528
{{xpdn|#expr:24*|CURRENTDAY|-24}} {{#expr:24*{{CURRENTDAY}}-24}} gives 504
{{xpdn|#expr:4*|#expr:not 0| >3}} {{#expr: 4*{{#expr:not 0}} >3}} gives 1
{{xpdn|urlencode:|DIRMARK}} {{urlencode:{{DIRMARK}}}} gives %E2%80%8E

Examples with additional parameters (no nesting possible):

{{xpd|#ifeq: 1.00|+1|okay}} {{#ifeq: 1.00|+1|okay}} gives okay
{{xpd|#ifeq: this|that||false|s=is}} {{#ifeq: this|that||false}} is false
{{xpd|t|b}} {{t|b}} gives start-b-end
{{xpd|t2|b|c}} {{t2|b|c}} gives Template:T2

In the case of one or more named parameters, write all parameter definitions from that as value of the appropriate parameter number, e.g.:

{{xpd|t link|2=wikt=abc|3=}} gives "{{t link|wikt=abc|}} gives Template:T link"

Optional substitution with subst=subst: is not supported. The demo template shows what another template actually does, and not what it did some time ago.

Separator parameter

Usage:
{{xpd|left side|up to 3 additional parameters|s=separator}}
{{xpdn|left side|nested part and optional last part|s=separator}}
The default separator is "gives", use s== or similar to get "=" etc.

Examples with separator parameter:

{{xpd|CURRENTDAY|s=is}} {{CURRENTDAY}} is 22
{{xpd|1=#expr:2+2|s==}} {{#expr:2+2}} = 4
{{xpdn|#expr:4*|#expr:not 0| >3 | yields}} {{#expr: 4*{{#expr:not 0}} >3 }} yields 1