模板:Tlx/doc:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
创建页面,内容为“This template is used to show example template usage without expanding the template itself. == Basic use == ''(Note: In the following examples, Ellipsis|ellipses…”
 
Kangkk​(留言 | 贡献)
 
(未显示同一用户的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{{\sandbox}}|tlx|Template|''first parameter''|''second parameter''|''third''|...|''twentieth''}} produces: {{tlx{{\sandbox}}|Template|''first parameter''|''second parameter''|''third''|...|''twentieth''}}
: {{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{{\sandbox}}|tlx|Template|''first''<nowiki>{{=}}</nowiki>''something''|''second''|''third''<nowiki>{{=}}</nowiki>''something''|...|twentieth}} produces: {{tlx{{\sandbox}}|Template|''first{{=}}something''|''second''|''third{{=}}something''|...|''twentieth''}}
: {{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 {{tag|nowiki}} thus:
For more than ten parameters, possibly also containing equals-signs, use <nowiki>...</nowiki> thus:
: {{tlx{{\sandbox}}|tlx|Template|&lt;nowiki><nowiki>''first''|''second''|''third=something''|...|''999th''</nowiki>&lt;/nowiki>}} produces: {{tlx{{\sandbox}}|Template|<nowiki>first|second|third=something|...|999th</nowiki>}}
: {{tlx|tlx|Template|&lt;nowiki><nowiki>''first''|''second''|''third=something''|...|''999th''</nowiki>&lt;/nowiki>}} produces: {{tlx|Template|<nowiki>first|second|third=something|...|999th</nowiki>}}


== Purpose and naming ==
== Purpose and naming ==
* If the only parameter supplied is {{param|1}}, i.e. a template's name, {{tlx|tlx}}'s output is the same as {{tlx|tl}}&nbsp;&ndash; i.e. a link within [[Braces (punctuation)|braces]]&nbsp;&ndash; but in a [[monospaced font]]:
* 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}}&nbsp;&ndash; i.e. a link within [[Braces (punctuation)|braces]]&nbsp;&ndash; but in a [[monospaced font]]:
** {{tc|tl|tl}} produces: {{tl|tl}}
** <nowiki>{{tl|tl}}</nowiki> produces: {{tl|tl}}
** {{tc|tlx|tl}} produces: {{tlx{{\sandbox}}|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
{{para|subst}}
<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{{\sandbox}}|tlx|Welcome|3=subst=Y}} produces: {{tlx{{\sandbox}}|Welcome|subst=Y}}. This is similar to the action of the {{tlx{{\sandbox}}|tlxs}} template: {{tlx{{\sandbox}}|tlxs|Welcome}} produces: {{tlxs|Welcome}}.
: 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.
{{para|SISTER}}
<nowiki>|SISTER</nowiki>
: For an interwiki link to [[H:IW|other sister projects]], such as: {{para|SISTER|M:}} ([[m:|Meta]]), {{para|SISTER|Q:}} ([[q:|WikiQuote]]), {{para|SISTER|S:}} ([[s:|WikiSource]]), etc, facilitating interwiki template documentation and/or discussion.
: 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.
{{para|LANG}}
: For a link to [[H:ILL|Wikipedias in other languages]], such as: {{para|LANG|de:}} ([[:de:|German]]), {{para|LANG|sv:}} ([[:sv:|Swedish]]), etc, facilitating cross-language 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 "{{thin space}}'''{'''{{thin space}}", "{{thin space}}'''&#124;'''{{thin space}}", "{{thin space}}'''}'''{{thin space}}" 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).
{{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 " '''{''' ", " '''&#124;''' ", " '''}''' " 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{{\sandbox}}|x0}}            | &#160;
  | {{tlx|tlx|x0}}                | {{tlx|x0}}            | &#160;
  | {{tlx|tlx|Abc}}                | {{tlx{{\sandbox}}|Abc}}            | &#160;
  | {{tlx|tlx|Abc}}                | {{tlx|Abc}}            | &#160;
  | {{tlx|tlx|ABC}}                | {{tlx{{\sandbox}}|ABC}}            | &#160;
  | {{tlx|tlx|ABC}}                | {{tlx|ABC}}            | &#160;
  | {{tlx|tlx|AbC}}                | {{tlx{{\sandbox}}|AbC}}            | &#160;
  | {{tlx|tlx|AbC}}                | {{tlx|AbC}}            | &#160;
  | {{tlx|tlx|x1|one}}            | {{tlx{{\sandbox}}|x1|one}}        | &#160;
  | {{tlx|tlx|x1|one}}            | {{tlx|x1|one}}        | &#160;
  | {{tlx|tlx|x2|one|two}}        | {{tlx{{\sandbox}}|x2|one|two}}    | &#160;
  | {{tlx|tlx|x2|one|two}}        | {{tlx|x2|one|two}}    | &#160;
  <!--(Parameter number:)-->
  <!--(Parameter number:)-->
  | {{tlx|tlx|x3|1|2|3|4|5|6|7|8|9&#124;10}}            | {{tlx{{\sandbox}}|x3|1|2|3|4|5|6|7|8|9|10}}        | &#160;
  | {{tlx|tlx|x3|1|2|3|4|5|6|7|8|9&#124;10}}            | {{tlx|x3|1|2|3|4|5|6|7|8|9|10}}        | &#160;
  | {{tlx|tlx|x4|1|2|3|4|5|6|7|8|9&#124;10&#124;11}}    | {{tlx{{\sandbox}}|x4|1|2|3|4|5|6|7|8|9|10|11}}      | up to 10 parameters...
  | {{tlx|tlx|x4|1|2|3|4|5|6|7|8|9&#124;10&#124;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&#124;10&amp;#124;11}} | {{tlx{{\sandbox}}|x5|1|2|3|4|5|6|7|8|9|10&#124;11}} | {{align|right|...<code>&amp;#124;</code> for more}}
  | {{tlx|tlx|x5|1|2|3|4|5|6|7|8|9&#124;10&amp;#124;11}} | {{tlx|x5|1|2|3|4|5|6|7|8|9|10&#124;11}} | ...<code>&amp;#124;</code> for more
  <!--(Equals-sign:)-->
  <!--(Equals-sign:)-->
  | {{tlx|tlx|x1|x&#61;u}}              | {{tlx{{\sandbox}}|x1|x=u}}        | the straightforward equals-sign won't work...
  | {{tlx|tlx|x1|x&#61;u}}              | {{tlx|x1|x=u}}        | the straightforward equals-sign won't work...
  | {{tlx|tlx|x1|x&amp;#61;u}}          | {{tlx{{\sandbox}}|x1|x&#61;u}}    | {{align|right|...but <code>&amp;#61;</code> is okay}}
  | {{tlx|tlx|x1|x&amp;#61;u}}          | {{tlx|x1|x&#61;u}}    | ...but <code>&amp;#61;</code> is okay
  | {{tlx|tlx|x1|x<nowiki>{{=}}</nowiki>u}} | {{tlx{{\sandbox}}|x1|x{{=}}u}} | {{align|right|...and <code><nowiki>{{=}}</nowiki></code> is okay}}
  | {{tlx|tlx|x1|x<nowiki>{{=}}</nowiki>u}} | {{tlx|x1|x{{=}}u}} | ...and <code><nowiki>{{=}}</nowiki></code> is okay
  | {{tlx|tlx|x1|&lt;nowiki&gt;x&#61;u&lt;/nowiki&gt;}} | {{tlx{{\sandbox}}|x1|<nowiki>x=u</nowiki>}} | {{align|right|sticky nowiki also okay}}
  | {{tlx|tlx|x1|&lt;nowiki&gt;x&#61;u&lt;/nowiki&gt;}} | {{tlx|x1|<nowiki>x=u</nowiki>}} | sticky nowiki also okay
  <!--(Empty/space/pipe:)-->
  <!--(Empty/space/pipe:)-->
  | {{tlx|tlx|x2|&#160;|two}}          | {{tlx{{\sandbox}}|x2| |two}}        | empty won't work...
  | {{tlx|tlx|x2|&#160;|two}}          | {{tlx|x2| |two}}        | empty won't work...
  | {{tlx|tlx|x2|&amp;#32;|two}}        | {{tlx{{\sandbox}}|x2|&#32;|two}}    | {{align|right|...but <code>&amp;#32;</code> is okay}}
  | {{tlx|tlx|x2|&amp;#32;|two}}        | {{tlx|x2|&#32;|two}}    | ...but <code>&amp;#32;</code> is okay
  | {{tlx|tlx|x2|&amp;nbsp;|two}}      | {{tlx{{\sandbox}}|x2|&nbsp;|two}}    | {{align|right|...<code>&amp;nbsp;</code> is also okay}}
  | {{tlx|tlx|x2|&amp;nbsp;|two}}      | {{tlx|x2|&nbsp;|two}}    | ...<code>&amp;nbsp;</code> is also okay
  | {{tlx|tlx|x2|{{tag|nowiki|s}}|two}} | {{tlx{{\sandbox}}|x2|<nowiki/>|two}} | {{align|right|{{tag|nowiki|s}} handles the space}}
  | {{tlx|tlx|x2|<nowiki><nowiki /></nowiki>|two}} | {{tlx|x2|<nowiki/>|two}} | <nowiki><nowiki /></nowiki> handles the space
  | {{tlx|tlx|x2| &amp;#124; two}}      | {{tlx{{\sandbox}}|x2| &#124; two}}  | {{align|right|<code>&amp;#124;</code> is okay}}
  | {{tlx|tlx|x2| &amp;#124; two}}      | {{tlx|x2| &#124; two}}  | <code>&amp;#124;</code> is okay
  | {{tlx|tlx|x2| {&#123;!&#125;} two}} | {{tlx{{\sandbox}}|x2 | {{!}} two}}  | {{align|right|<nowiki>{{!}}</nowiki> is dubious}}
  | {{tlx|tlx|x2| {&#123;!&#125;} two}} | {{tlx|x2 | {{!}} two}}  | <nowiki>{{!}}</nowiki> is dubious


  | {{tlx|tlx|x2|<nowiki>2=</nowiki>|<nowiki>3=two</nowiki>}} | {{tlx{{\sandbox}}|x2|2=|3=two}} | empty really doesn't work
  | {{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{{\sandbox}}|x2|two}} | "two" overrides "2{{=}}one"
  | {{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{{\sandbox}}|x2|3=two|2=one}} | {{align|right|irregular parameter order is okay}}
  | {{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 {{tag|nowiki}} string  
; Unlimited parameters as one <nowiki><nowiki>...</nowiki></nowiki> string  
: {{tlx{{\sandbox}}|tlx|convert|<nowiki>&lt;nowiki>14|m|ftin|abbr=out|sp=us&lt;/nowiki></nowiki>}}
: {{tlx|tlx|convert|<nowiki>&lt;nowiki>14|m|ftin|abbr=out|sp=us&lt;/nowiki></nowiki>}}
 
== See also ==
* {{tl|tlxb}}, a version of {{tlf|tlx}} where the template name is shown in bold.
*: {{tl|tlb}}, a version of {{tlf|tl}} where the template name is shown in bold.
* {{tl|temt}}, a version of {{tlf|tlx}} that handles templates whose names include "Template:" and pages outside the Template: [[Wikipedia:Namespace|namespace]] that are treated as templates.
* {{tl|para}}, for the presentation of template parameters and values (e.g. {{para|paraname|val}}, {{para|another}}).
* {{tl|tnull}}, like {{tnull|tlx}} without linking the template.
 
== Template-linking templates ==


<!-- 本行下加入模板(Documentation)的分类 -->
<!-- 本行下加入模板(Documentation)的分类 -->