zh.m.wikipedia.org
Template:Template sandbox notice
这是​Template:Template sandbox notice差异)的沙盒
模板文档[查看] [编辑] [历史] [清除缓存]
請勿在此測試編輯功能!
只有​沙盒​(Sandbox)或您的​用户页​(Userpage)可以用作測試。
此模板目前缺乏相關中文​使用說明​
請能清楚敘述本模板的用途及使用方法的編輯者協助​編寫說明文件​或者翻譯其他語言版本。
本模板可能使用了​模板參數​,若無完整的使用說明將不便於他人了解、引用、維護與修改。

This is the {{template sandbox notice}} template.
It can be placed on template /sandbox pages. It also detects when it is not on a /sandbox page and then shows nothing, thus it can be left in the code when copied and pasted to the main template. (Although most users remove the sandbox notice when they copy the code from the /sandbox to the main template. But beware, if the notice-not-sandbox parameter has been used then the sandbox notice must be copied with the rest of the template code. See more below.)
To learn more about how to use template /sandbox and /testcases subpages see Wikipedia:Template test cases.
Simple example
<!-- template code --><noinclude> {{template sandbox notice}} </noinclude>
Note! The template code must start directly before and physically touch the <noinclude> tag. Any blank space or newlines between the template code and the <noinclude> tag can cause the template to render unwanted spaces or newlines when used.
Non-standard "/sandbox" and "/testcases" names
This template uses case-insensitive matching, so will match "/Sandbox", "/SandBox", "/sAnDbOx" etc. without any special help.
If the /sandbox page has another name, for instance "/sandbag", then you need to tell the sandbox notice the name of the page, so that it knows when to show and when not to show itself. Like this:
<!-- Template code --><noinclude> {{template sandbox notice | subpage-name=sandbag }} </noinclude>
If the testcases page has another name, this may be specified using the testcases-name parameter:
<!-- Template code --><noinclude> {{template sandbox notice | testcases-name=testbox}} </noinclude>
Provided there is only one sandbox or testcases page in use for the particular main page, another option is to move the sandbox page to the standard "/sandbox" name, or testcases to "/testcases". That may be preferable since other templates and tools also assume that the sandbox uses that name, such as {{documentation}}.
Showing and hiding other things
The sandbox notice can also help showing and hiding other things depending on if it detects it is on the /sandbox page or not. Like this:
<!-- Template code --><noinclude> {{template sandbox notice | notice-for-sandbox = Text that shows on the /sandbox page. | notice-not-sandbox = Text that will show on other pages. }} <!-- Text for all pages goes here --> </noinclude>
Protection template example
The notice-not-sandbox parameter can for instance be used so a protection template can be placed already in the /sandbox version of the code. (See also Wikipedia:Protection policy.) Like this:
<!-- Template code --><noinclude> {{template sandbox notice | notice-not-sandbox = {{pp-semi-template|small=yes}} }} </noinclude>
Documentation example
Some templates have their documentation on a separate /doc page, and then show that documentation in a green doc box below the template code by using the {{documentation}} template. (See also Wikipedia:Template documentation.) Then place the sandbox notice like this:
<!-- Template code --><noinclude> {{template sandbox notice}} {{documentation}} <!-- Add categories and interwikis to the /doc subpage, not here! --> </noinclude>
Super deluxe example
This example handles both a protection template and a green doc box from a /doc page at the same time. (See also Wikipedia:Protection policy and Wikipedia:Template documentation.) Like this:
<!-- Template code --><noinclude> {{template sandbox notice | notice-for-sandbox = Text that shows on the /sandbox page. | notice-not-sandbox = {{pp-semi-template|small=yes}} }} {{documentation}} <!-- Add categories and interwikis to the /doc subpage, not here! --> </noinclude>
Copy, paste & delete
The following "complete" example can be used to copy and paste into your template, then delete the parts you don't need:
<!-- Template code --><noinclude> {{template sandbox notice | notice-for-sandbox = | notice-not-sandbox = <!-- Protection templates as big message boxes --> {{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}} <!-- Protection templates as small icons --> {{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}} <!-- End protection templates, stop deleting, keep next line --> }} <!-- Text for all pages goes here --> {{documentation}} <!-- Add categories and interwikis to the /doc subpage, not here! --> </noinclude>
Technical details
If there is an accompanying "/testcases" page this template will detect that and show a link to the /testcases page.
This template categorises /sandbox pages into Category:Template sandboxes. If you don't want a page to be categorised then use the template like this:
{{template sandbox notice|category=}}
If you want to demonstrate the template on say Wikipedia:Template messages/Template namespace then you need to feed the subpage-name to make it show and feed an empty category parameter so it doesn't categorise the page. Like this:
{{template sandbox notice|subpage-name=Template namespace|category=}}
See also
上述​文档​嵌入​自​Template:Template sandbox notice/doc。 (编辑 | 历史)
编者可以在本模板的沙盒 (编辑 | 差异)和测试样例 (创建)页面进行实验。
请在​/doc​子页面中添加分类。​本模板的子页面​
最后编辑于2018年9月2日 (星期日) 12:10
维基百科
除非另有声明,本网站内容采用​CC BY-SA 3.0授权。
隐私政策
使用条款
桌面版
首页随机 附近 登录 设置 资助维基百科关于维基百科免责声明
语言监视编辑