跳至內容

模板: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}}

參見

[編輯]