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

另请参见