跳转到内容

Template:Tlg/doc

本页使用了标题或全文手工转换
维基百科,自由的百科全书

{{template link general}},常缩写为{{tlg}},其功能是为模板名称的显示提供样式化格式,而无需实际调用该模板。生成的代码将以行内形式呈现。

参数

[编辑]

alttext外,所有命名参数均为开关型参数,它们通常可以省略,或通过赋值(如on、yes、true、include等)来激活。这些参数可按任意顺序排列(参见下方示例)。部分模板默认开启特定参数,所有可用的替代选项请查阅主表格。若某行显示效果与上一行完全相同,则表示当前模板不支持该选项,需改用{{tlg}}实现。

参数 功能描述 与{{example}}联用示例 默认激活的模板
默认状态(不使用任何辅助参数) {{example}}
brace 将双层大括号作为模板链接的一部分显示 {{example}} {{tlw}}/{{tn}}
braceinside 将内层大括号作为模板链接的一部分显示 {{example}}
bold 将模板链接/名称以粗体形式显示 {{example}} {{tlb}}、{{tlxb}}
code 使用HTML <code>...</code>标签(以等宽字体)显示输出 {{example}} {{tlc}}、{{Template link expanded}}等
italic 将模板链接/名称之后的参数以斜体形式显示 {{example|param}} {{tlxi}}
kbd 使用HTML <kbd>...</kbd>标签(等宽字体)显示输出 {{example}}
nolink 不为模板名称添加内部链接 {{example}} {{tlf}}、{{tnull}}
nowrap 在输出内容中禁用自动换行(nowrap) {{example}} {{tlf}}、{{tlp}}
nowrapname 在模板名称/链接的输出中禁用自动换行(参数部分在必要时仍会换行) {{example}}
plaincode 使用样式为“border:none; background:transparent;”的<code>...</code>标签 {{example}} {{tltss}}
subst 在模板链接/名称前添加subst:前缀 {{subst:example}} {{tls}}、{{tlxs}}等
alttext=[text] 将模板链接的显示文本替换为自定义文本[text] {{Other}} {{tla}}
_show_result 同时显示调用该模板后的实际渲染结果 {{Min|7|-5}} → -5
_expand 添加指向该模板展开后页面的链接 {{Min|7|-5}} [1]
a 在模板代码前添加一个星号(*) * {{Min|7|-5}}

匿名参数

[编辑]

本模板可以接受不限数量的匿名参数,这些参数将作为模板链接(或名称)的附加参数一同显示;具体用法请参见下方示例。

範例

[编辑]
代码 输出 备注
{{tlg|Example}} {{Example}}
{{tlg|ExAmple}} {{ExAmple}} 模板名称区分大小写
{{tlg|example}} {{example}} 首字母不区分大小写
{{tlg|x0}} {{x0}}
{{tlg|x0|code=on}} {{x0}} <code>样式
{{tlg|x0|plaincode=on}} {{x0}} plaincode样式
{{tlg|x0|bold=on}} {{x0}} 链接/名称加粗
{{tlg|x1|one|italic=on}} {{x1|one}} 参数以斜体显示
{{tlg|x0|nolink=on}} {{x0}}
{{tlg|x0|subst=on}} {{subst:x0}}
{{tlg|x0|braceinside=on}} {{x0}}
{{tlg|x0|alttext=x0 link}} {{x0 link}}
{{tlg|x0|bold=on|code=on|braceinside=on}} {{x0}} 可以组合使用多个参数设置
{{tlg|x1|one}} {{x1|one}}
{{tlg|x2|one|two}} {{x2|one|two}}
{{tlg|x2|bold=on|code=on|one|two}} {{x2|one|two}} 可以组合使用命名参数和匿名参数……
{{tlg|x2|one|two|bold=on|code=on}} {{x2|one|two}} ……以任意顺序……
{{tlg|x2|one|code=on|two|bold=on|three}} {{x2|one|two|three}} ……甚至可以交错排列……
{{tlg|x2|one|code=on|two|bold=on|three|italic=on}} {{x2|one|two|three}} ……并形成多种不同的配置。
{{tlg|x3|1|2|3|4|5|6|7|8|9|10}} {{x3|1|2|3|4|5|6|7|8|9|10}}
{{tlg}} {{Template:Tlg/doc}} 若无参数,则自动代入当前页面名称
{{tlg|x1|x=u}} {{x1}} =符号无法直接使用
{{tlg|x1|x&#61;u}} {{x1|x=u}}
&#61;可以正常使用
{{tlg|x1|x{{=}}u}} {{x1|x=u}}
{{=}}可以正常使用
{{tlg|x1|x<nowiki>=</nowiki>u}} {{x1|x=u}}
nowiki标签可以正常使用
{{tlg|x2||two||}} {{x2|two}} 空参数同样有效,即使位于末尾
{{tlg|x2|3=two|2=one}} {{x2|one|two}}
从右到左也可以正常处理
长名称的换行处理(默认情况)
代码 输出
{{tlg|long template name that would wrap to new line|this is a long value for the 1st parameter that would wrap}} {{long template name that would wrap to new line|this is a long value for the 1st parameter that would wrap}}
长名称的换行处理(nowrap=on
代码 输出
{{tlg|nowrap: on|long template name that would wrap to new line|long value for the 1st parameter that would wrap}} {{long template name that would wrap to new line|long value for the 1st parameter that would wrap}}
长名称的换行处理(nowrapname=on
代码 输出
{{tlg|nowrapname: on|long template name that would wrap to new line|long value for the 1st parameter that would wrap}} {{long template name that would wrap to new line|long value for the 1st parameter that would wrap}}

参见

[编辑]
連結形式 → 含有連結 不含連結 含有連結並添加subst 含有連結,連結包含括號 含有連結,顯示其他文字 第一個|替換成:
文字樣式 ↓ {{tlg}}選項1 nolink=yes subst=yes braceinside=yes alttext=FOO 不適用
正常 {{tl}} · {{tlp}}2 · {{tlg}}1, 2 {{tlf}}2 · {{tnull}} {{tls}} · {{tlsp}} {{tn}} {{tla}} {{tlm}}3
代碼 code code=yes or
tt=yes
{{tlx}} {{tlc}}2 · {{tld}} {{tlxs}}   {{tlxm}}3
代碼 syntaxhighlight 不適用   {{tlsh}}   {{tlshm}}
粗體 bold=yes {{tlb}}  
粗體代碼 code bold=yes|code=yes {{tlxb}}
斜體代碼 code italic=yes|code=yes {{tlxi}}
註釋:1. {{tlg}}是功能最齊全的模板,可選用任何配搭的文字樣式、連結形式。

2. 用<span class="nowrap">...</span>標籤將文字包圍,防止斷行。

3. 包含偵測到的解析器函數的連結
各顯示樣式的比較
  • {{tlf|Milford Haven Line|弘安源氏論議}}{{Milford Haven Line|弘安源氏論議}}
  • {{tld|Milford Haven Line|弘安源氏論議}}{{Milford Haven Line|弘安源氏論議}}
  • {{tlc|Milford Haven Line|弘安源氏論議}}{{Milford Haven Line|弘安源氏論議}}
添加參數
  • {{para|name|{{var|value}}}}|name=value
  • {{para|name|{{varserif|value}}}}|name=value
  • {{tlx|Milford Haven Line|參數1{{=}}賦值1}}{{Milford Haven Line|參數1=賦值1}}

參見

[编辑]