模板:Template sandbox notice

被永久保護的模板
維基百科,自由的百科全書
文件圖示 模板文件[檢視] [編輯] [歷史] [清除快取]

這是{{模板沙盒通知}}模板。

它可放置在模板的/sandbox頁面上。它還會檢測是否位於/sandbox頁面,如果不是,則不顯示任何內容,因此可以在複製和粘貼到主模板時保留在代碼中。(雖然大多數用戶在從/sandbox複製代碼到主模板時會刪除沙盒通知。但請注意,如果使用了'notice-not-sandbox'參數,則必須將沙盒通知與其餘模板代碼一起複製。詳見下文。)

要了解有關如何使用模板的/sandbox和/testcases子頁面的更多信息,請參閱Wikipedia:Template test cases

簡單示例

<!-- 模板代码 --><noinclude>

{{template sandbox notice}}
</noinclude>

注意! 模板代碼必須直接在 <noinclude> 標籤之前並物理接觸到該標籤。模板代碼和 <noinclude> 標籤之間的任何空格或換行符都可能導致在使用時呈現不想要的空格或換行符。

非標準的"/sandbox"和"/testcases"名稱

此模板使用不區分大小寫的匹配,因此會匹配"/Sandbox"、"/SandBox"、"/sAnDbOx"等等,無需任何特殊幫助。

如果/sandbox頁面有另一個名稱,例如"/sandbag",則需要告訴沙盒通知頁面的名稱,以便它知道何時顯示自己和何時不顯示自己。如下所示:

<!-- 模板代码 --><noinclude>

{{template sandbox notice | subpage-name=sandbag }}
</noinclude>

如果testcases頁面有另一個名稱,則可以使用testcases-name參數進行指定:

<!-- 模板代码 --><noinclude>

{{template sandbox notice | testcases-name=testbox}}
</noinclude>

只要特定主頁面只使用一個sandbox或testcases頁面,另一種選擇是將sandbox頁面移動到標準的"/sandbox"名稱,或將testcases移動到"/testcases"。這可能更可取,因為其他模板和工具也假定沙盒使用該名稱,例如{{documentation}}。

顯示和隱藏其他內容

沙盒通知還可以根據是否檢測到其位於/sandbox頁面上來幫助顯示和隱藏其他內容。如下所示:

<!-- 模板代码 --><noinclude>

{{template sandbox notice
| notice-for-sandbox = 在/sandbox页面上显示的文本。
| notice-not-sandbox = 在其他页面上显示的文本。
}}
<!-- 所有页面的文本放在这里 -->
</noinclude>

保護模板示例

'notice-not-sandbox'參數可以用於在代碼的/sandbox版本中放置保護模板。 (另請參見Wikipedia:Protection policy。)如下所示:

<!-- 模板代码 --><noinclude>

{{template sandbox notice
| notice-not-sandbox = {{pp-semi-template|small=yes}}
}}
</noinclude>

文檔示例

一些模板的文檔位於單獨的/doc頁面上,並且通過使用{{documentation}}模板在模板代碼下方顯示綠色的文檔框。 (另請參見Wikipedia:Template documentation。)然後將沙盒通知放置如下:

<!-- 模板代码 --><noinclude>

{{template sandbox notice}}
{{documentation}}
<!-- 将分类和interwikis添加到/doc子页面,不要在这里添加! -->
</noinclude>

超級豪華示例

此示例同時處理了保護模板和/doc頁面中的綠色文檔框。 (另請參見Wikipedia:Protection policyWikipedia:Template documentation。)如下所示:

<!-- 模板代码 --><noinclude>

{{template sandbox notice
| notice-for-sandbox = 在/sandbox页面上显示的文本。
| notice-not-sandbox = {{pp-semi-template|small=yes}}
}}
{{documentation}}
<!-- 将分类和interwikis添加到/doc子页面,不要在这里添加! -->
</noinclude>

複製、粘貼和刪除

以下「完整」示例可用於複製和粘貼到您的模板中,然後刪除不需要的部分:

<!-- 模板代码 --><noinclude>

{{template sandbox notice
| notice-for-sandbox =
| notice-not-sandbox =
<!-- 保护模板作为大型消息框 -->
{{pp-dispute}}
{{pp-office}}
{{pp-move}}
{{pp-protected}}
{{pp-template}}
{{pp-usertalk}}
{{pp-vandalism}}
{{pp-semi-protected}}
{{pp-semi-sock}}
{{pp-semi-spambot}}
{{pp-semi-template}}
{{pp-semi-usertalk}}
{{pp-semi-vandalism}}
<!-- 保护模板作为小图标 -->
{{pp-dispute|small=yes}}
{{pp-office|small=yes}}
{{pp-move|small=yes}}
{{pp-protected|small=yes}}
{{pp-template|small=yes}}
{{pp-usertalk|small=yes}}
{{pp-vandalism|small=yes}}
{{pp-semi-protected|small=yes}}
{{pp-semi-sock|small=yes}}
{{pp-semi-spambot|small=yes}}
{{pp-semi-template|small=yes}}
{{pp-semi-usertalk|small=yes}}
{{pp-semi-vandalism|small=yes}}
<!-- 结束保护模板,停止删除,保持下一行 -->
}}
<!-- 所有页面的文本放在这里 -->
{{documentation}}
<!-- 将分类和interwikis添加到/doc子页面,不要在这里添加! -->
</noinclude>

技術細節

如果有附帶的"/testcases"頁面,此模板將檢測到並顯示到/testcases頁面的連結。

此模板將/sandbox頁面分類為Category:Template sandboxes。如果不希望頁面被分類,則可以使用以下模板:

{{template sandbox notice|category=}}

如果要演示模板,請參見Wikipedia:Template messages/Template namespace,則需要提供'subpage-name'以顯示它,並提供空的'category'參數,以便不對頁面進行分類。如下所示:

{{template sandbox notice|subpage-name=Template namespace|category=}}

另請參見