ਫਰਮਾ:Xpd/doc
ਇਹ ਇੱਕ ਫਰਮਾ:Xpd ਲਈ documentation ਉਪ ਸਫ਼ਾ ਹੈ। ਇਸ ਵਿੱਚ ਵਰਤੋਂ ਦੀ ਜਾਣਕਾਰੀ, ਸ਼੍ਰੇਣੀਆਂ ਅਤੇ ਹੋਰ ਸਮੱਗਰੀ ਜੋ ਮੂਲ ਦਾ ਹਿੱਸਾ ਨਹੀਂ ਹੈ, ਸ਼ਾਮਲ ਹੈ। ਫਰਮਾ page. |
The expansion demo templates (see [1]) show, for documentation:
- some wikitext
- its rendering
- a link to ExpandTemplates applied to the wikitext; thus it shows:
- The expanded wikitext.
- The rendering of this expanded wikitext
Template:xpd (backlinks edit) selects one of the following four templates based on the number of unnamed parameters
- Template:xpd0 (backlinks edit) - simplified version of m:Template:xpdoc (backlinks, edit)
- Template:xpd1 (backlinks edit) - simplified version of m:Template:xpdopec (backlinks, edit)
- Template:xpd2 (backlinks edit) - simplified version of m:Template:xpdopepec (backlinks, edit)
- Template:xpd3 (backlinks edit) - simplified version of m:Template:xpdopepepec (backlinks, edit)
Examples
[ਸੋਧੋ]{{xpd|CURRENTDAY}} gives:
"{{CURRENTDAY}}"
gives "24" [2]
{{xpd|#expr:2+2}} gives:
"{{#expr:2+2}}"
gives "4" [3]
For more examples see the separate templates.
Separator parameter
[ਸੋਧੋ]The default separator is "gives". With gives={{!}}{{!}} to get "||" for use in a table, the same separator is used before the ExpandTemplates link.
Example:
{| class="wikitable" !wikitext!!result!!ExpandTemplates |- |{{xpd|CURRENTDAY|gives={{!}}{{!}}}} |- |{{xpd|#expr:2+2|gives={{!}}{{!}}}} |}
gives
wikitext | result | ExpandTemplates |
---|---|---|
"{{CURRENTDAY}}" |
"24" | [4] |
"{{#expr:2+2}}" |
"4" | [5] |
Quotes
[ਸੋਧੋ]The quotation marks are needed to see spaces and newlines at the start and end of the result. In other expand demo templates they are also needed to see spaces and newlines at the start and end of the wikitext, and to get a result independent of whether it starts on a line due to parameter {{{gives}}}.
Limitations
[ਸੋਧੋ]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 are not supported. Neither are equals signs in parameter values of the template or parser function demonstrated.
Examples:
- {{xpd|1x| p{{=}}q }} gives
"{{1x|p=q}}"
gives " p=q " "`UNIQ--gallery-0000000D-QINU`"'__p%3Dq%7D%7D%22 - 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 {{1x| p{{=}}q
}} gives p=q [6]. - {{xpd|1x|2= p=q }} gives
"{{1x|p=q}}"
gives "p=q" "`UNIQ--gallery-00000012-QINU`"'__p%3Dq%7D%7D%22 - 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 {{xpdopec|1x|1|3= p=q }} giving"{{1x|1=p=q}}"
gives "p=q" "`UNIQ--gallery-00000026-QINU`"'__%22_'"`UNIQ--gallery-00000027-QINU`"'__%7B_'"`UNIQ--gallery-00000028-QINU`"'__%7B_'"`UNIQ--gallery-00000029-QINU`"'__1x_'"`UNIQ--gallery-0000002A-QINU`"'__%7c_'"`UNIQ--gallery-0000002B-QINU`"'__1_'"`UNIQ--gallery-0000002C-QINU`"'__%3d_'"`UNIQ--gallery-0000002D-QINU`"'__p%3Dq_'"`UNIQ--gallery-0000002E-QINU`"'__%7D_'"`UNIQ--gallery-0000002F-QINU`"'__%7D_'"`UNIQ--gallery-00000030-QINU`"'___'"`UNIQ--gallery-00000031-QINU`"'___'"`UNIQ--gallery-00000032-QINU`"'___'"`UNIQ--gallery-00000033-QINU`"'___'"`UNIQ--gallery-00000034-QINU`"'___'"`UNIQ--gallery-00000035-QINU`"'___'"`UNIQ--gallery-00000036-QINU`"'___'"`UNIQ--gallery-00000037-QINU`"'___'"`UNIQ--gallery-00000038-QINU`"'___'"`UNIQ--gallery-00000039-QINU`"'___'"`UNIQ--gallery-0000003A-QINU`"'___'"`UNIQ--gallery-0000003B-QINU`"'__%22_'"`UNIQ--gallery-0000003C-QINU`"'___'"`UNIQ--gallery-0000003D-QINU`"'__&removecomments=true or {{xpdnp|1x|1n=1|1v= p=q }} giving ਫਰਮਾ:Xpdnp (spaces and newlines are trimmed). - {{xpd|t np|q=s}} gives:
"{{t np}}"
gives "ਫਰਮਾ:T np" [7] ("q=s" is ignored); instead, use {{xpdopec|t np|q|s}} giving"{{t np|q=s}}"
gives "ਫਰਮਾ:T np" "`UNIQ--gallery-00000054-QINU`"'__%22_'"`UNIQ--gallery-00000055-QINU`"'__%7B_'"`UNIQ--gallery-00000056-QINU`"'__%7B_'"`UNIQ--gallery-00000057-QINU`"'__t+np_'"`UNIQ--gallery-00000058-QINU`"'__%7c_'"`UNIQ--gallery-00000059-QINU`"'__q_'"`UNIQ--gallery-0000005A-QINU`"'__%3d_'"`UNIQ--gallery-0000005B-QINU`"'__s_'"`UNIQ--gallery-0000005C-QINU`"'__%7D_'"`UNIQ--gallery-0000005D-QINU`"'__%7D_'"`UNIQ--gallery-0000005E-QINU`"'___'"`UNIQ--gallery-0000005F-QINU`"'___'"`UNIQ--gallery-00000060-QINU`"'___'"`UNIQ--gallery-00000061-QINU`"'___'"`UNIQ--gallery-00000062-QINU`"'___'"`UNIQ--gallery-00000063-QINU`"'___'"`UNIQ--gallery-00000064-QINU`"'___'"`UNIQ--gallery-00000065-QINU`"'___'"`UNIQ--gallery-00000066-QINU`"'___'"`UNIQ--gallery-00000067-QINU`"'___'"`UNIQ--gallery-00000068-QINU`"'___'"`UNIQ--gallery-00000069-QINU`"'__%22_'"`UNIQ--gallery-0000006A-QINU`"'___'"`UNIQ--gallery-0000006B-QINU`"'__&removecomments=true or {{xpdnp|t np|1n=q|1v=s}} giving ਫਰਮਾ:Xpdnp.
Even in the case of a parser function called with a parameter containing an equals sign the template for named parameters should be used:
- {{xpd|#if:x|p=q}} gives:
"{{#if:x}}"
gives "" [8] ("p=q" is ignored); instead, use {{xpdnp|#if:x|1n=p|1v=q}} giving ਫਰਮਾ:Xpdnp.
Rendering of left side
[ਸੋਧੋ]If no value for parameter p is given, the left-hand side, before "gives", does not show the literal wikitext of the parameters of the template or parser function demonstrated, but the rendering. This affects e.g. sequences of more than two spaces, and single newlines. Also link code is shown as a link. Furthermore, any templates and parser functions in the parameters are expanded; m:Template:xpdn (backlinks, edit) covers the simpler of such cases.
Examples:
{{xpd|1x|[[Help:L{{tc}}k]]}} {{xpd|t1|p q}}
gives:
"{{1x|[[Help:Link]]}}"
gives "Help:Link" "`UNIQ--gallery-00000073-QINU`"'__%5B%5BHelp%3ALink%5D%5D%7D%7D%22
"{{t1|p
q}}"
gives "{{[[Template:p
q|p
q]]}}" "`UNIQ--gallery-00000076-QINU`"'__p%0Aq%7D%7D%22
With substitution of xpd1 etc. (see below) and putting nowiki tags around the list of parameters the left hand side is corrected.
Also the input text of ExpandTemplates in the supplied link is the result of expanding the parameters.
Spaces and newlines
[ਸੋਧੋ]If parameters start or end with a space or newline, these are preserved. Even if the left-hand side, as mentioned, does not show the raw wikitext of the parameters but the rendering, the right-hand side gives the correct result.
Substitution
[ਸੋਧੋ]- {{subst:xpd|substnp=subst:|tc}} gives the wikitext {{xpd0|tc}}
- {{subst:xpd|substnp=subst:|t1|p}} gives the wikitext {{xpd1|t1|p}}
- {{subst:xpd|substnp=subst:|t2|p|q}} gives the wikitext {{xpd2|t2|p|q}}
- {{subst:xpd|substnp=subst:|concat|p|q|r}} gives the wikitext {{xpd3|concat|p|q|r}}
Note that except in the case of long and complicated parameters, adding the number of parameters after "xpd" is easier than adding "subst:" and "|substnp=subst:".
With substitution of xpd1 etc. and putting nowiki tags around the list of parameters the left hand side is given literally without conversions, see also above.
See also
[ਸੋਧੋ]- Template:xpd0 (backlinks edit) - simplified version of m:Template:xpdoc (backlinks, edit)
- Template:xpd1 (backlinks edit) - simplified version of m:Template:xpdopec (backlinks, edit)
- Template:xpd2 (backlinks edit) - simplified version of m:Template:xpdopepec (backlinks, edit)
- Template:xpd3 (backlinks edit) - simplified version of m:Template:xpdopepepec (backlinks, edit)
- m:Template:xpdt1 (backlinks, edit) for table row templates
- m:Template:xpdnp (backlinks, edit) for named parameters
- Xpd templates
- m:Template:tlx (backlinks, edit) - produces just the template call, with the template name linked to the template, but not the result, e.g.
"{{tlx|t2|b|c}}"
gives "{{t2|b|c}}
" [9]