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

来自康健生活
Kangkk​(留言 | 贡献)
无编辑摘要
Kangkk​(留言 | 贡献)
 
(未显示同一用户的3个中间版本)
第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>}}


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

2020年3月2日 (一) 17:35的最新版本

This template is used to show example template usage without expanding the template itself.

Basic use

(Note: In the following examples, ellipses (groups of three dots) indicate where parameters have been omitted.)

{{tlx|Template|first parameter|second parameter|third|...|twentieth}} produces: {{Template|first parameter|second parameter|third|...|twentieth}}

Where parameters might contain one or more equals-signs ("="), replace each equals-sign with {{=}}:

{{tlx|Template|first{{=}}something|second|third{{=}}something|...|twentieth}} produces: {{Template|first=something|second|third=something|...|twentieth}}

For more than ten parameters, possibly also containing equals-signs, use ... thus:

{{tlx|Template|<nowiki>''first''|''second''|''third=something''|...|''999th''</nowiki>}} produces: {{Template|first|second|third=something|...|999th}}

Purpose and naming

  • If the only parameter supplied is {{{1}}}, i.e. a template's name, {{tlx}}'s output is the same as {{tl}} – i.e. a link within braces – but in a monospaced font:
    • {{tl|tl}} produces:

{{tl}}

    • {{tlx|tl}} produces: {{tl}}
{{tl}} will also not take nor display additional parameters.
Named parameters

|subst

Setting this parameter to any non-blank value will prefix the string subst: linked to Help:Substitution. This is useful to indicate when a template should be substituted. For example, {{tlx|Welcome|subst=Y}} produces: {{subst:Welcome}}. This is similar to the action of the {{tlxs}} template: {{tlxs|Welcome}} produces: Welcome.

|SISTER

For an interwiki link to other sister projects, such as: |SISTER=M, |SISTER=Q, |SISTER=S, etc, facilitating interwiki template documentation and/or discussion.

Documentation

{{Tlx}} is a generalization of {{tl}}, {{tlp}} 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 {{!}}, see {{tlw}}, which makes the click target bigger).

Usage

{{tlx|Templatename}}
{{tlx|Templatename|param}}
{{tlx|Templatename|1|2|3|4|5|6|7|8|9|10}}
{{tlx|Templatename|1|2|3|4|5|6|7|8|9|10&#124;more}}
{{tlx|Templatename|param&#61;value}}

There are up to 10 placeholders for parameters of the specified template.

Examples

Note
At the en.wikipedia and Meta sites, X0, X1, X2, ... X9 are sandbox templates for experimentation on involved templates that need be in template space. An auto-cleansing software facility exists that might be used to duplicate the facility on other sister projects.
Code Result Remarks
{{tlx|x0}} {{x0}}  
{{tlx|Abc}} {{Abc}}  
{{tlx|ABC}} {{ABC}}  
{{tlx|AbC}} {{AbC}}  
{{tlx|x1|one}} {{x1|one}}  
{{tlx|x2|one|two}} {{x2|one|two}}  
{{tlx|x3|1|2|3|4|5|6|7|8|9|10}} {{x3|1|2|3|4|5|6|7|8|9|10}}  
{{tlx|x4|1|2|3|4|5|6|7|8|9|10|11}} {{x4|1|2|3|4|5|6|7|8|9|10|11}} up to 10 parameters...
{{tlx|x5|1|2|3|4|5|6|7|8|9|10&#124;11}} {{x5|1|2|3|4|5|6|7|8|9|10|11}} ...&#124; for more
{{tlx|x1|x=u}} {{x1}} the straightforward equals-sign won't work...
{{tlx|x1|x&#61;u}} {{x1|x=u}} ...but &#61; is okay
{{tlx|x1|x{{=}}u}} {{x1|x=u}} ...and {{=}} is okay
{{tlx|x1|<nowiki>x=u</nowiki>}} {{x1|x=u}} sticky nowiki also okay
{{tlx|x2| |two}} {{x2|two}} empty won't work...
{{tlx|x2|&#32;|two}} {{x2| |two}} ...but &#32; is okay
{{tlx|x2|&nbsp;|two}} {{x2| |two}} ...&nbsp; is also okay
{{tlx|x2|<nowiki />|two}} {{x2||two}} <nowiki /> handles the space
{{tlx|x2| &#124; two}} {{x2| | two}} &#124; is okay
{{tlx|x2| {{!}} two}} {{x2 | | two}} {{!}} is dubious
{{tlx|x2|2=|3=two}} {{x2|two}} empty really doesn't work
{{tlx|x2|2=one|two}} {{x2|two}} "two" overrides "2=one"
{{tlx|x2|3=two|2=one}} {{x2|one|two}} irregular parameter order is okay
Unlimited parameters as one <nowiki>...</nowiki> string
{{tlx|convert|<nowiki>14|m|ftin|abbr=out|sp=us</nowiki>}}