Template:Namespace detect/doc

Description
This metatemplate is used to help other templates detect which namespace they are in.

It detects and groups the different namespaces on The Sims Wiki into four types:


 * main: The main or article namespace, where the wiki's content articles are kept.
 * talk: Any talk page, including page names that start with "Talk:", "User talk:", "File talk:", etc.
 * user · the sims wiki · file · mediawiki · template · help · category (etc.): The remaining namespaces that serve various different purposes.
 * other: Any namespace that isn't specified as a parameter in this template.

NB: It is probably easier to use templates like Checkmns and Checkfns that only check to see if they're in one specific namespace. This template is meant to be a "catch-all" template that supports all namespaces.

Usage
This template takes one or more parameters named after the different page types as listed above, like this:

If the template is on an article page (mainspace), it will return this:



If the template is on any other page than an article or a talk page, it will return this:



The example above made the template return something for all page types; however, if we don't use the other parameter or leave it empty, it will not return anything for the other page types. Like this:

If the template is used on any pages other than File or Category pages, it will not display anything.

You can use this trick to make the template not render anything for a specific page type, like this:

The above won't display anything on mainspace (article) pages, but on all other pages it will display this:



Testing and debugging parameters
Because of the nature of this template, testing it can be difficult at times. To help with this, this template has two parameters that allows you to easily test to see how the template will behave in other namespaces without actually having to use this template in those namespaces.

The demospace parameter understands any of the page types used in this template, including the other type. It instructs the template to behave as if it were on a specific type of page. For example:

No matter where the template is used, it will always act as if it were in the main namespace, like this:



The page parameter takes the full name of a page, making this template behave as if it were on that page. The page you specify in question doesn't actually have to exist. For example:

Will cause the template to always act as if it were used on User:Example, like this:



If both demospace and page are used, demospace will take prevalence, and page will be ignored.

Renders as:



If you want your template to be able to understand the demospace and page parameters, you can do something like this:

If both the demospace and page parameters are left blank, the template will detect page types like normal.

Credits
This template's code was copied from K6ka's Wiki on ShoutWiki. This template documentation was taken partially from there as well.