模板:Tlx/doc:修订间差异
来自康健生活
创建页面,内容为“This template is used to show example template usage without expanding the template itself. == Basic use == ''(Note: In the following examples, Ellipsis|ellipses…” |
|||
| (未显示同一用户的4个中间版本) | |||
| 第4行: | 第4行: | ||
''(Note: In the following examples, [[Ellipsis|ellipses (groups of three dots)]] indicate where parameters have been omitted.)'' | ''(Note: In the following examples, [[Ellipsis|ellipses (groups of three dots)]] indicate where parameters have been omitted.)'' | ||
: {{tlx | : {{tlx|tlx|Template|''first parameter''|''second parameter''|''third''|...|''twentieth''}} produces: {{tlx|Template|''first parameter''|''second parameter''|''third''|...|''twentieth''}} | ||
Where parameters might contain one or more equals-signs ("="), replace each equals-sign with {{tlf|{{=}}}}: | Where parameters might contain one or more equals-signs ("="), replace each equals-sign with {{tlf|{{=}}}}: | ||
: {{tlx | : {{tlx|tlx|Template|''first''<nowiki>{{=}}</nowiki>''something''|''second''|''third''<nowiki>{{=}}</nowiki>''something''|...|twentieth}} produces: {{tlx|Template|''first{{=}}something''|''second''|''third{{=}}something''|...|''twentieth''}} | ||
For more than ten parameters, possibly also containing equals-signs, use | For more than ten parameters, possibly also containing equals-signs, use <nowiki>...</nowiki> thus: | ||
: {{tlx | : {{tlx|tlx|Template|<nowiki><nowiki>''first''|''second''|''third=something''|...|''999th''</nowiki></nowiki>}} produces: {{tlx|Template|<nowiki>first|second|third=something|...|999th</nowiki>}} | ||
== Purpose and naming == | == Purpose and naming == | ||
* If the only parameter supplied is {{ | * If the only parameter supplied is <nowiki>{{{1}}}</nowiki>, i.e. a template's name, {{tlx|tlx}}'s output is the same as {{tlx|tl}} – i.e. a link within [[Braces (punctuation)|braces]] – but in a [[monospaced font]]: | ||
** {{ | ** <nowiki>{{tl|tl}}</nowiki> produces: {{tl|tl}} | ||
** {{ | ** <nowiki>{{tlx|tl}}</nowiki> produces: {{tlx|tl}} | ||
: {{tlx|tl}} will also not take nor display additional parameters. | : {{tlx|tl}} will also not take nor display additional parameters. | ||
; Named parameters | ; Named parameters | ||
<nowiki>|subst</nowiki> | |||
: Setting this parameter to any non-blank value will prefix the string <code>subst:</code> linked to [[Help:Substitution]]. This is useful to indicate when a template should be substituted. For example, {{tlx | : Setting this parameter to any non-blank value will prefix the string <code>subst:</code> linked to [[Help:Substitution]]. This is useful to indicate when a template should be substituted. For example, {{tlx|tlx|Welcome|3=subst=Y}} produces: {{tlx|Welcome|subst=Y}}. This is similar to the action of the {{tlx|tlxs}} template: {{tlx|tlxs|Welcome}} produces: Welcome. | ||
<nowiki>|SISTER</nowiki> | |||
: For an interwiki link to [[H:IW|other sister projects]], such as: | : For an interwiki link to [[H:IW|other sister projects]], such as: <nowiki>|SISTER=M</nowiki>, <nowiki>|SISTER=Q</nowiki>, <nowiki>|SISTER=S</nowiki>, etc, facilitating interwiki template documentation and/or discussion. | ||
== Documentation == | == Documentation == | ||
{{tl|Tlx}} is a generalization of {{tl|tl|x}}, {{tl|tlp|x|y}} etc., with output that is arguably more legible. This depends on the browser, but narrow gaps between characters such as " | {{tl|Tlx}} is a generalization of {{tl|tl|x}}, {{tl|tlp|x|y}} etc., with output that is arguably more legible. This depends on the browser, but narrow gaps between characters such as " '''{''' ", " '''|''' ", " '''}''' " and links can be hard to read when not monospaced (and hard to click on; for uses like <code><nowiki>{{!}}</nowiki></code>, see {{tl|tlw}}, which makes the click target bigger). | ||
===Usage=== | ===Usage=== | ||
| 第47行: | 第44行: | ||
|row1style=background:whitesmoke;font-weight:bold; | |row1style=background:whitesmoke;font-weight:bold; | ||
| Code | Result | Remarks | | Code | Result | Remarks | ||
| {{tlx|tlx|x0}} | {{tlx | | {{tlx|tlx|x0}} | {{tlx|x0}} |   | ||
| {{tlx|tlx|Abc}} | {{tlx | | {{tlx|tlx|Abc}} | {{tlx|Abc}} |   | ||
| {{tlx|tlx|ABC}} | {{tlx | | {{tlx|tlx|ABC}} | {{tlx|ABC}} |   | ||
| {{tlx|tlx|AbC}} | {{tlx | | {{tlx|tlx|AbC}} | {{tlx|AbC}} |   | ||
| {{tlx|tlx|x1|one}} | {{tlx | | {{tlx|tlx|x1|one}} | {{tlx|x1|one}} |   | ||
| {{tlx|tlx|x2|one|two}} | {{tlx | | {{tlx|tlx|x2|one|two}} | {{tlx|x2|one|two}} |   | ||
<!--(Parameter number:)--> | <!--(Parameter number:)--> | ||
| {{tlx|tlx|x3|1|2|3|4|5|6|7|8|9|10}} | {{tlx | | {{tlx|tlx|x3|1|2|3|4|5|6|7|8|9|10}} | {{tlx|x3|1|2|3|4|5|6|7|8|9|10}} |   | ||
| {{tlx|tlx|x4|1|2|3|4|5|6|7|8|9|10|11}} | {{tlx | | {{tlx|tlx|x4|1|2|3|4|5|6|7|8|9|10|11}} | {{tlx|x4|1|2|3|4|5|6|7|8|9|10|11}} | up to 10 parameters... | ||
| {{tlx|tlx|x5|1|2|3|4|5|6|7|8|9|10&#124;11}} | {{tlx | | {{tlx|tlx|x5|1|2|3|4|5|6|7|8|9|10&#124;11}} | {{tlx|x5|1|2|3|4|5|6|7|8|9|10|11}} | ...<code>&#124;</code> for more | ||
<!--(Equals-sign:)--> | <!--(Equals-sign:)--> | ||
| {{tlx|tlx|x1|x=u}} | {{tlx | | {{tlx|tlx|x1|x=u}} | {{tlx|x1|x=u}} | the straightforward equals-sign won't work... | ||
| {{tlx|tlx|x1|x&#61;u}} | {{tlx | | {{tlx|tlx|x1|x&#61;u}} | {{tlx|x1|x=u}} | ...but <code>&#61;</code> is okay | ||
| {{tlx|tlx|x1|x<nowiki>{{=}}</nowiki>u}} | {{tlx | | {{tlx|tlx|x1|x<nowiki>{{=}}</nowiki>u}} | {{tlx|x1|x{{=}}u}} | ...and <code><nowiki>{{=}}</nowiki></code> is okay | ||
| {{tlx|tlx|x1|<nowiki>x=u</nowiki>}} | {{tlx | | {{tlx|tlx|x1|<nowiki>x=u</nowiki>}} | {{tlx|x1|<nowiki>x=u</nowiki>}} | sticky nowiki also okay | ||
<!--(Empty/space/pipe:)--> | <!--(Empty/space/pipe:)--> | ||
| {{tlx|tlx|x2| |two}} | {{tlx | | {{tlx|tlx|x2| |two}} | {{tlx|x2| |two}} | empty won't work... | ||
| {{tlx|tlx|x2|&#32;|two}} | {{tlx | | {{tlx|tlx|x2|&#32;|two}} | {{tlx|x2| |two}} | ...but <code>&#32;</code> is okay | ||
| {{tlx|tlx|x2|&nbsp;|two}} | {{tlx | | {{tlx|tlx|x2|&nbsp;|two}} | {{tlx|x2| |two}} | ...<code>&nbsp;</code> is also okay | ||
| {{tlx|tlx|x2| | | {{tlx|tlx|x2|<nowiki><nowiki /></nowiki>|two}} | {{tlx|x2|<nowiki/>|two}} | <nowiki><nowiki /></nowiki> handles the space | ||
| {{tlx|tlx|x2| &#124; two}} | {{tlx | | {{tlx|tlx|x2| &#124; two}} | {{tlx|x2| | two}} | <code>&#124;</code> is okay | ||
| {{tlx|tlx|x2| {{!}} two}} | {{tlx | | {{tlx|tlx|x2| {{!}} two}} | {{tlx|x2 | {{!}} two}} | <nowiki>{{!}}</nowiki> is dubious | ||
| {{tlx|tlx|x2|<nowiki>2=</nowiki>|<nowiki>3=two</nowiki>}} | {{tlx | | {{tlx|tlx|x2|<nowiki>2=</nowiki>|<nowiki>3=two</nowiki>}} | {{tlx|x2|2=|3=two}} | empty really doesn't work | ||
| {{tlx|tlx|x2|<nowiki>2=one</nowiki>|two}} | {{tlx | | {{tlx|tlx|x2|<nowiki>2=one</nowiki>|two}} | {{tlx|x2|two}} | "two" overrides "2{{=}}one" | ||
| {{tlx|tlx|x2|<nowiki>3=two</nowiki>|<nowiki>2=one</nowiki>}} | {{tlx | | {{tlx|tlx|x2|<nowiki>3=two</nowiki>|<nowiki>2=one</nowiki>}} | {{tlx|x2|3=two|2=one}} | irregular parameter order is okay | ||
}} | }} | ||
; Unlimited parameters as one | ; Unlimited parameters as one <nowiki><nowiki>...</nowiki></nowiki> string | ||
: {{tlx | : {{tlx|tlx|convert|<nowiki><nowiki>14|m|ftin|abbr=out|sp=us</nowiki></nowiki>}} | ||
<!-- 本行下加入模板(Documentation)的分类 --> | <!-- 本行下加入模板(Documentation)的分类 --> | ||