Difference between revisions of "Template:Xpd"

From MINR.ORG WIKI
(from meta)
 
(quotes)
Line 1: Line 1:
<noinclude>{{hh}}</noinclude><includeonly>{&#123;<small>&#160;</small><code>{{{1}}}{{#if:{{{1n|}}}|</code>{&#123;<code>{{{1n}}}</code>&#125;}<code>}}{{{1a|}}}{{#ifeq:{{{4|+}}}|{{{4|-}}}|<b>&#124;</b>{{{2|}}}<b>&#124;</b>{{{3|}}}<b>&#124;</b>{{{4|}}}|{{#ifeq:{{{3|-}}}|{{{3|+}}}|<b>&#124;</b>{{{2|}}}<b>&#124;</b>{{{3|}}}|{{#ifeq:{{{2|-}}}|{{{2|+}}}|<b>&#124;</b>{{{2|}}}|}}}}}}</code>&#125;} {{{s|gives}}} {{#ifeq:{{{4|-}}}|{{{4|+}}}|{{{{{1{{{{{1n|void}}}}}{{{1a|}}}}}}|{{{2|}}}|{{{3|}}}|{{{4|}}}}}|{{#ifeq:{{{3|-}}}|{{{3|+}}}|{{{{{1}}}{{{{{1n|void}}}}}{{{1a|}}}|{{{2|}}}|{{{3|}}}}}|{{#ifeq:{{{2|-}}}|{{{2|+}}}|{{{{{1}}}{{{{{1n|void}}}}}{{{1a|}}}|{{{2|}}}}}|{{{{{1}}}{{{{{1n|void}}}}}{{{1a|}}}}}}}}}}}</includeonly><noinclude>
+
<noinclude>{{hh}}</noinclude><includeonly>{&#123;<small>&#160;</small><code>{{{1}}}{{#if:{{{1n|}}}|</code>{&#123;<code>{{{1n}}}</code>&#125;}<code>}}{{{1a|}}}{{#ifeq:{{{4|+}}}|{{{4|-}}}|<b>&#124;</b>{{{2|}}}<b>&#124;</b>{{{3|}}}<b>&#124;</b>{{{4|}}}|{{#ifeq:{{{3|-}}}|{{{3|+}}}|<b>&#124;</b>{{{2|}}}<b>&#124;</b>{{{3|}}}|{{#ifeq:{{{2|-}}}|{{{2|+}}}|<b>&#124;</b>{{{2|}}}|}}}}}}</code>&#125;} {{{s|gives}}} "{{#ifeq:{{{4|-}}}|{{{4|+}}}|{{{{{1{{{{{1n|void}}}}}{{{1a|}}}}}}|{{{2|}}}|{{{3|}}}|{{{4|}}}}}|{{#ifeq:{{{3|-}}}|{{{3|+}}}|{{{{{1}}}{{{{{1n|void}}}}}{{{1a|}}}|{{{2|}}}|{{{3|}}}}}|{{#ifeq:{{{2|-}}}|{{{2|+}}}|{{{{{1}}}{{{{{1n|void}}}}}{{{1a|}}}|{{{2|}}}}}|{{{{{1}}}{{{{{1n|void}}}}}{{{1a|}}}}}}}}}}}"</includeonly><noinclude>
 
This template {{tim|evd}} shows the call of a template or predefined template and its result, for documentation.<b>&#124;</b>
 
This template {{tim|evd}} shows the call of a template or predefined template and its result, for documentation.<b>&#124;</b>
  

Revision as of 14:26, 8 May 2007

Template:Hh This template Template:Tim shows the call of a template or predefined template and its result, for documentation.|

Usage:
{{Xpd|left side|up to 3 additional parameters}}
{{Xpd|left side|up to 3 additional parameters|s=separator}}
The default separator is "gives", use s== or similar to get "=" etc. Please note that for colon functions the first parameter belongs to the left side before the "|" vertical bar aka pipe.

Examples without additional parameters:

Examples:

  1. {{Xpd|CURRENTDAY|s=is}} displays
    {{ CURRENTDAY}} is "22"
  2. {{Xpd|#expr:2*3}} displays
    {{ #expr:2*3}} gives "6"
  3. {{Xpd|1=#expr:2+2=5}} displays
    {{ #expr:2+2=5}} gives "0"
  4. {{Xpd|1=#expr:(2+2=4)|s==}} displays
    {{ #expr:(2+2=4)}} = "1"
  5. {{Xpd|urlencode:!|s=&#61;}} displays
    {{ urlencode:!}} = "%21"
  6. {{Xpd|uc:abc} gives
    {{ uc:abc}} gives "ABC"
  7. {{subst:Xpd|uc:Upper Case|subst=subst:}} substitutes
    {{ subst:uc:Upper Case}} gives UPPER CASE
    See Help:Substitution for several caveats wrt subst=subst:.

As always the expression (first parameter) cannot directly contain "|", "=", plus other special cases related to square brackets / curly braces. In the case of this template "not directly" means "never" except from "=" as shown above.

This template and Template:Lts can be used if the case of an expression in double braces which itself includes a pair of double braces (simple nested expressions). For the former, use named parameters 1n (Nested part of first parameter) and optionally 1a (part After that). For the latter, use "|" for the inner "{{" and, if there is code after it, also for "}}".

  1. {{evd|#expr:24*|1n=CURRENTDAY}} gives Template:Evd
  2. {{evdn|#expr:24*|CURRENTDAY}} gives Template:Evdn
  3. {{evd|#expr:24*|1n=CURRENTDAY|1a=-24}} gives Template:Evd
  4. {{evdn|#expr:24*|CURRENTDAY|-24}} gives Template:Evdn
  5. {{evdn|#expr:4*|#expr:not 0| >3 | yields}} displays
    Template:Evdn
  6. {{evdn|urlencode:|DIRMARK}} displays
    Template:Evdn

Examples with additional parameters (no nesting possible):

Example:
{{Xpd|#ifeq: 1.00|+1|okay}} gives:
{{ #ifeq: 1.00|+1|okay}} gives "okay"
Example:
{{Xpd|#ifeq: this|that||false|is}} gives:
{{ #ifeq: this|that||false}} gives "false"
Example:
{{Xpd|#expr: 3*4}} gives:
{{ #expr: 3*4}} gives "12"
Example:
{{evaldemo|#expr: 3*4}} gives:
Template:Evaldemo
{{ tc}} gives "{{tlc|...}}"
{{ t|b}} gives "{{b}}"
{{ t|b|c}} yields "{{b}}"
{{ t2|b|c}} gives "Template:T2"
{{ t2|b|c|d}} gives "Template:T2"
{{ t2|b|c|d}} yields "Template:T2"

Optional substitution with subst=subst: is not supported. It's anyway against the spirit of this demo template showing what another template actually does, and not what it did some time ago.