Visit Mozilla.org

MDC:自訂樣板

From MDC

本文件正在翻譯中,請參考原文協助翻譯。
如何協助 MDC:內容
清單
文件需求清單
編輯、檢視待辦事項
需搬移的文件清單
指南
開始動手
寫作指南 (含體例)
頁面命名原則
消歧義
開創新的 MDC 本地化專案
授權方式
參考文件
Wiki 標籤參考
自訂 CSS 類別
自訂樣板
MediaWiki 擴充功能
站外連結轉向
待轉向
MDC 正體中文
正體中文版
翻譯方法及須知

本文列出一些為了 MDC 而製作的樣板,完整列表請見所有頁面的「樣板」名字空間。大部分的樣板頁都有簡單使用教學,在此就不全部列出。

也可延伸閱讀 Wiki 標籤參考本站自訂的 CSS 樣式類別列表

目錄

[編輯] 中文名稱

為了方便記憶,有的樣板會同時具備中英文名稱,使用時兩者皆宜。舉例來說,「連結錨點」的樣板名稱為「anch」或「錨」,那麼以下兩種方式都可以用:

 {{anch|top}} {{錨|top}}

而建立連往樣板頁面的方法也就有四種:

 [[Template:anch]] [[Template:錨]] [[樣板:anch]] [[樣板:錨]]

如樣板有中文名稱,會於文中一併標示,但文章中的範例以英文為主。

[編輯] 超連結

[編輯] Template:anch

用以插入至某連結錨點(anchor)的連結,例如 {{anch|top}} 會產生 <a href="#top">top</a>(top)。要注意的是用此方法無法以不同於錨點名稱的字串當連結文字,例如無法以此將名為 top 的錨點以 <a href="#top">頂端</top> 的方式顯示,因為這個樣板主要是為了快速製作錨點連結而生。

此樣板中文名稱為

[編輯] Template:bug

Template:bug 讓你可以輕鬆建立連至 bugzilla.mozilla.org 上某程式錯誤記錄的網址,只要將錯誤編號列為參數就行了。例如 {{bug|123456}} 會得到 bug 123456 這樣的連結。

[編輯] Template:enter-bug

Template:enter-bug lets you link to a Enter bug page on bugzilla.mozilla.org with specific product and component. For example, <code>{{enter-bug|Core|Testing}} shows up as 樣板:enter-bug.

[編輯] Template:LXRSearch

Template:LXRSearch can be used (somewhat painlessly) to create an LXR search URL. The syntax is as follows: {{LXRSearch|type|param|search-string|link-text}}. The parameters are used in the following ways:

  • type must be one of search (a string search through source), find (a file name search), or ident (a search through token names in Mozilla source).
  • param must be one of string (for string/file name searches) or i (for token searches). If templates had some conditional power we could get away with one parameter instead of two, but they don't. An extension could probably work around this, as always.
  • search-string is whatever you'd type in the search box on LXR if you were doing the search there, except that spaces should be converted to +.
  • link-text is the text for the link that will be created.

[編輯] Template:source

Template:source allows you to link to a Mozilla source code file without having to type a long LXR URL using this syntax: {{source|browser/Makefile.in}}. This gives you: 樣板:source. The text of the link is the path provided; to use something else as text see Template:named-source.

  • Ideally we could have a third parameter here for link text, but this isn't possible with MediaWiki right now (bug). It has been suggested that coding an extension for this should be easy:
It seems that noone has mentioned what's the simplest solution to this template problem: Extensions
<if input="{{{1}}}" matches="asdf">text to output</if>
making an extension like that would be trivial
you could just have it skip producing output if the input was ^\{{3}.*?\}{3}$"

[編輯] Linking to pages in references

Usage: {{cssxref|color}}: color.

The template saves you some typing over normal pipe-link: [[CSS:color|color]].

[編輯] 標記頁面

這些樣板是放在頁面的最上方(不過在 breadcrumb 導覽列下面),有些也能放在某個區段的前面。

[編輯] Template:Translation

Template:Translation 用以標示翻譯中文件,使用時請放在網頁頂端並附上原文網址,例如

 {{Translation|http://developer.mozilla.org/en/docs/MDC:Custom_Templates}}

會產生

本文件正在翻譯中,請參考原文協助翻譯。

這個樣板中文名稱為翻譯中,加入後同時會將該頁面歸為待翻譯類別。

[編輯] Template:disambig

Template:disambig 適用於標示消歧義用的其他頁面。

[編輯] Template:outdated 及 Template:NeedsTechnicalReview

This template should be used to tag pages that are known to be (or might be) horribly outdated. It's most commonly used when an old page is migrated from mozilla.org to MDC.

The template is followed by an optional parameter, which can be used to provide details. Example: {{outdated|It was last updated in 1999.}} gives you this:

樣板:outdated

A similar template, Template:NeedsTechnicalReview is for less hopeless cases when an author or an editor was unsure if something he read or wrote was technically correct. {{NeedsTechnicalReview}} results in: 樣板:NeedsTechnicalReview

[編輯] Template:LockedPage

Template:LockedPage inserts a mark bar across the page that provides an explanation for why a page is locked. There are two parameters: the first is the length of time for which the page is expected to be locked, and the second is the reason why it's locked. A link to the page's discussion page is also included in the bar. 樣板:LockedPage

[編輯] Template:deprecated_header, non-standard_header, obsolete_header

Template:deprecated_header 會在文件中插入「棄用」標示,以提醒使用者這個函式、方法或屬性已正式宣告棄用,文件中最好別用。通常這個棄用標題都會直接放在函式等相關說明文件之標題(或導覽列)的下方。

此樣板中文名稱為棄用標題,使用方法為 {{deprecated_header}},結果如下:

已正式宣告棄用

類似的樣板還有 Template:non-standard_headerTemplate:obsolete_header,can be used to mark non-standard and obsolete functionality. Usage: {{non-standard_header}} or {{obsolete_header}}. Result: 樣板:non-standard header 樣板:obsolete header

[編輯] Templates tagging pages in the references/guides/tutorials

There are a number of templates for almost each large collection of pages (such as the DOM reference. They typically link back to the main page of the reference/guide/tutorial (this is often needed because our breadcrumbs sometimes can't do this) and put the article in the appropriate category.

E.g.: Template:DomRef, Template:CSSRef, Template:jsapiref, ... (yes, the capitalization inconsistency sucks)

[編輯] 其他通用樣板

[編輯] Template:block-title

Template:block-title可用以插入一段以粗體顯示的文字,同時有連結錨點功能。與一般標題較為不同之處是,用這種方法插入的小標題不會顯示於自動生成之目錄中。

樣本:block-title 的使用語法為{{block-title|標題}},其中的「標題」便是你想顯示的文字,此文字同時也是本文的連結錨點之一。區段小標可放在表格、圖片、程式碼區段等日後想由其他文件直接連結參考的資料處。

此樣板中文名稱為小標

[編輯] Template:Clr

Template:Clr 這個樣板會在頁面中插入 <br style="clear:both;" /> 以確保不會有任何浮動圖表影響此樣本之後的頁面排版。只要在文中放入 {{Clr}}即可。

留心:這個樣板可能會影響頁面排版甚鉅,使用時請多預覽幾次。

[編輯] Template:Note and Template:warning

Template:Note inserts a specially-formatted "note" block into the article's text. This is intended to call out an interesting or important fact. It uses the "note" CSS class. Using the template instead of directly using the class allows us to make more changes to the appearance of the notes more easily in the future. Usage: {{Note|This is an important note.}}. Result:

註: This is an important note.

Similarly, Template:warning inserts a specially-formatted "warning" block. {{warning|Danger, Will Robinson!}} results in:

Warning sign
小心: Danger, Will Robinson!

As you can see, the warning block includes a large icon and is currently used for article headings (via Template:outdated). You might want to use div class="warning" instead.

[編輯] Template:ref 及 Template:note

Template:refTemplate:note 可以做出文章的頁尾附註。這種附註在文件中標示的「數字」部分可以用 {{ref|something}} 來製作(其中的 something 應為自定的適切文字,建議用英文),接著於文件最後插入類似這樣的程式碼以建立頁尾附註列表:

# {{note|something}} 拉拉嚕拉拉,這是第一個頁尾附註。
# {{note|something-else}} 芭樂八八八,這是另一個頁尾附註
# ...

這兩個樣板中文名稱分別為參照頁尾附註

[編輯] Template:deprecated_inline

Template:deprecated_inline 插入一個棄用註腳標示,以告知使用者此函式(或方法、屬性等)已然宣告棄用,文件中請避免使用。使用方法為{{deprecated_inline}},例如:

  • 第一項
  • 第二項 已棄用
  • 第三項

此樣本的中文名稱為已棄用

[編輯] Template:non-standard_inline

Template:non-standard_inline inserts an in-line non-standard mark to discourage the use of e.g. a function, method, property, or attribute which has not been standardized. Usage: {{non-standard_inline}}. Example:

[編輯] Template:obsolete_inline

Template:obsolete_inline inserts an in-line obsolete mark to prevent the use of e.g. a function, method or property which is officially obsolete. Usage: {{obsolete_inline}}. Example:

[編輯] Template:Previous、Template:Next 及 Template:PreviousNext

Template:PreviousTemplate:NextTemplate:PreviousNext 提供同系列文章的導覽功能。在「上一頁」及「下一頁」樣板中唯一參數便是該前往的 Wiki 頁面名稱;「上下頁」樣板則需要兩個參數,第一個是上一頁的 Wiki 頁名稱、第二個理所當然是下一頁的 Wiki 頁名稱。

這三個樣板的中文名稱分別為上一頁下一頁上下頁

[編輯] 版本資訊樣板

[編輯] 可能會刪掉?

[編輯] Template:sidenote

Due to limitations of templates in Mediawiki which prevent templates from being nested (e.g., {{sidenote|left|See also {{bug|123456}}.}}, where the end of the inner template is incorrectly parsed as the end of the outer template), this template should no longer be used. Instead, use the following:

<div class="side-note-left">...</div> <!-- for a left-floated sidebar -->
<div class="side-note-right">...</div> <!-- for a right-floated sidebar -->

[編輯] 延伸閱讀