|
|
Line 1: |
Line 1: |
| {{Documentation subpage}} | | {{Documentation subpage}} |
| The [[help:expansion demo templates|expansion demo templates]] (see [http://meta.wikimedia.org/w/index.php?title=Special%3APrefixIndex&prefix=xpd&namespace=10]) show, for documentation: | | The expansion demo templates (see [http://meta.wikimedia.org/w/index.php?title=Special%3APrefixIndex&prefix=xpd&namespace=10]) show, for documentation: |
| *some wikitext | | *some wikitext |
| *its rendering | | *its rendering |
Line 8: |
Line 8: |
|
| |
|
| {{tim|xpd}} selects one of the following four templates based on the number of unnamed parameters | | {{tim|xpd}} selects one of the following four templates based on the number of unnamed parameters |
| *{{tim|xpd0}} - simplified version of {{tim|xpdoc}} | | *{{tim|xpd0}} - simplified version of <nowiki>{{tim|xpdoc}}</nowiki> |
| *{{tim|xpd1}} - simplified version of {{tim|xpdopec}} | | *{{tim|xpd1}} - simplified version of <nowiki>{{tim|xpdopec}}</nowiki> |
| *{{tim|xpd2}} - simplified version of {{tim|xpdopepec}} | | *{{tim|xpd2}} - simplified version of <nowiki>{{tim|xpdopepec}}</nowiki> |
| *{{tim|xpd3}} - simplified version of {{tim|xpdopepepec}} | | *<nowiki>{{tim|xpd3}}</nowiki> - simplified version of <nowiki>{{tim|xpdopepepec}}</nowiki> |
|
| |
|
| ==Separator parameter== | | ==Separator parameter== |
Line 51: |
Line 51: |
|
| |
|
| ==Limitations== | | ==Limitations== |
| This Template:Xpd is a simplified version of some [[help:expansion demo templates|expansion demo templates]]. If necessary use the proper extended version. | | This Template:Xpd is a simplified version of some expansion demo templates. If necessary use the proper extended version. |
|
| |
|
| ===Named parameters and parameter values with equals signs=== | | ===Named parameters and parameter values with equals signs=== |
Line 58: |
Line 58: |
| Examples: | | Examples: |
| *<nowiki>{{xpd|1x| p{{=}}q }}</nowiki> gives {{xpd|1x| p{{=}}q }} - wrong result due to the template call in the parameter; is corrected by substitution and putting nowiki tags in the lefthand side (see below), giving {{<code>1x<b>|</b><nowiki> p{{=}}q</nowiki> </code>}} gives {{1x| p{{=}}q }} [{{fullurl:special:ExpandTemplates|input=%7B%7B{{urlencode:1x{{!}} p{{=}}q } }}%7D}}]. | | *<nowiki>{{xpd|1x| p{{=}}q }}</nowiki> gives {{xpd|1x| p{{=}}q }} - wrong result due to the template call in the parameter; is corrected by substitution and putting nowiki tags in the lefthand side (see below), giving {{<code>1x<b>|</b><nowiki> p{{=}}q</nowiki> </code>}} gives {{1x| p{{=}}q }} [{{fullurl:special:ExpandTemplates|input=%7B%7B{{urlencode:1x{{!}} p{{=}}q } }}%7D}}]. |
| *<nowiki>{{xpd|1x|2= p=q }}</nowiki> gives {{xpd|1x|2= p=q }} - wrong result because the lefthand side would be expanded interpreting p as named parameter, while the righthand side shows the result if the unnamed parameter of 1x has the given value; use <nowiki>{{xpdopec|1x|1|3= p=q }}</nowiki> giving {{xpdopec|1x|1|3= p=q }} or <nowiki>{{xpdnp|1x|1n=1|1v= p=q }}</nowiki> giving {{xpdnp|1x|1n=1|1v= p=q }} (spaces and newlines are trimmed). | | *<nowiki>{{xpd|1x|2= p=q }}</nowiki> gives {{xpd|1x|2= p=q }} - wrong result because the lefthand side would be expanded interpreting p as named parameter, while the righthand side shows the result if the unnamed parameter of 1x has the given value; use <nowiki>{{xpdopec|1x|1|3= p=q }}</nowiki> giving <nowiki>{{xpdopec|1x|1|3= p=q }}</nowiki> or <nowiki>{{xpdnp|1x|1n=1|1v= p=q }}</nowiki> giving <nowiki>{{xpdnp|1x|1n=1|1v= p=q }}</nowiki> (spaces and newlines are trimmed). |
| *<nowiki>{{xpd|t np|q=s}}</nowiki> gives: {{xpd|t np|q=s}} ("q=s" is ignored); instead, use <nowiki>{{xpdopec|t np|q|s}}</nowiki> giving {{xpdopec|t np|q|s}} or <nowiki>{{xpdnp|t np|1n=q|1v=s}}</nowiki> giving {{xpdnp|t np|1n=q|1v=s}}. | | *<nowiki>{{xpd|t np|q=s}}</nowiki> gives: <nowiki>{{xpd|t np|q=s}}</nowiki> ("q=s" is ignored); instead, use <nowiki>{{xpdopec|t np|q|s}}</nowiki> giving <nowiki>{{xpdopec|t np|q|s}}</nowiki> or <nowiki>{{xpdnp|t np|1n=q|1v=s}}</nowiki> giving <nowiki>{{xpdnp|t np|1n=q|1v=s}}</nowiki>. |
|
| |
|
| Even in the case of a parser function called with a parameter containing an equals sign the template for named parameters should be used: | | Even in the case of a parser function called with a parameter containing an equals sign the template for named parameters should be used: |
Line 95: |
Line 95: |
| Example with two newlines, hence also the left-hand side is correct: | | Example with two newlines, hence also the left-hand side is correct: |
|
| |
|
| {{xpdc|xpd|t2| p | | | <nowiki>{{xpdc|xpd|t2| p | |
|
| |
|
| q | | q |
|
| |
|
| }} | | }}</nowiki> |
| ---- | | ---- |
| Example without consecutive spaces inside a parameter value, hence also the left-hand side is correct: | | Example without consecutive spaces inside a parameter value, hence also the left-hand side is correct: |
|
| |
|
| "{{xpdc|xpd|concat| p | q }}" | | "<nowiki>{{xpdc|xpd|concat| p | q }}</nowiki>" |
|
| |
|
| ==Substitution== | | ==Substitution== |
Line 117: |
Line 117: |
| ==See also== | | ==See also== |
| *{{tim|xpd0}} - simplified version of {{tim|xpdoc}} | | *{{tim|xpd0}} - simplified version of {{tim|xpdoc}} |
| *{{tim|xpd1}} - simplified version of {{tim|xpdopec}} | | *{{tim|xpd1}} - simplified version of <nowiki>{{tim|xpdopec}}</nowiki> |
| *{{tim|xpd2}} - simplified version of {{tim|xpdopepec}} | | *{{tim|xpd2}} - simplified version of <nowiki>{{tim|xpdopepec}}</nowiki> |
| *{{tim|xpd3}} - simplified version of {{tim|xpdopepepec}} | | *<nowiki>{{tim|xpd3}}</nowiki> - simplified version of <nowiki>{{tim|xpdopepepec}}</nowiki> |
| *{{tim|xpdt1}} for table row templates | | *<nowiki>{{tim|xpdt1}}</nowiki> for table row templates |
| *{{tim|xpdnp}} for named parameters | | *{{tim|xpdnp}} for named parameters |
| *[http://meta.wikimedia.org/w/index.php?title=Special%3APrefixIndex&from=Xpd&namespace=10 Xpd templates] | | *[http://meta.wikimedia.org/w/index.php?title=Special%3APrefixIndex&from=Xpd&namespace=10 Xpd templates] |
|
| |
|
| *{{tim|tlx}} - produces just the template call, with the template name linked to the template, but not the result, e.g. {{xpd|tlx|t2|b|c}} | | *{{tim|tlx}} - produces just the template call, with the template name linked to the template, but not the result, e.g. <nowiki>{{xpd|tlx|t2|b|c}}</nowiki> |
|
| |
|
| *{{tiw|en|Xpd}} | | *<nowiki>{{tiw|en|Xpd}}</nowiki> |
| *{{tiw|no|Xpd}} | | *<nowiki>{{tiw|no|Xpd}}</nowiki> |
|
| |
|
| <includeonly><!-- CATEGORIES AND INTERWIKIS HERE, THANKS --> | | <includeonly><!-- CATEGORIES AND INTERWIKIS HERE, THANKS --> |