Template:Template sandbox notice

From MozillaWiki
Jump to: navigation, search
Documentation icon Template documentation[view] [edit] [history] [purge]

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.

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" 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>

Provided there is only one sandbox in use for the particular main page, another option is to move the sandbox page to the standard "/sandbox" name. 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>

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. Then place the sandbox notice like this:

<!-- Template code --><noinclude>
{{template sandbox notice}}
{{documentation}}
<!-- Please add this template's categories to the /doc subpage - thanks! -->
</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 =
}}
<!-- Text for all pages goes here -->
{{documentation}}
<!-- Please add this template's categories to the /doc subpage - thanks! -->
</noinclude>

Technical details

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 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=}}