Template:Single namespace/doc: Difference between revisions
meta>DixonDBot m Migrating 2 interwiki links, now provided by Wikidata on d:Q7481717 |
meta>Zyxw add examples, add category |
||
Line 2: | Line 2: | ||
{{Substitution|not}} | {{Substitution|not}} | ||
== Usage == | |||
This is a meta-template; it should only be used within other templates. It is used for namespace detection as a simplification of <code><nowiki>{{Foo other|Example|{{Incorrect namespace|foo}}}}</nowiki></code>. If the template is transcluded in the Foo namespace, it will transclude "Example"; if not, it will transclude {{tl|Incorrect namespace}}. Note that {{tl|Incorrect namespace}} does not work in the template namespace. | This is a meta-template; it should only be used within other templates. It is used for namespace detection as a simplification of <code><nowiki>{{Foo other|Example|{{Incorrect namespace|foo}}}}</nowiki></code>. If the template is transcluded in the Foo namespace, it will transclude "Example"; if not, it will transclude {{tl|Incorrect namespace}}. Note that {{tl|Incorrect namespace}} does not work in the template namespace. | ||
Line 9: | Line 9: | ||
The second parameter is optional. It allows something (usually a category) to be transcluded in the correct namespace. | The second parameter is optional. It allows something (usually a category) to be transcluded in the correct namespace. | ||
=== | == Examples == | ||
<includeonly> | === Correct namespace === | ||
<!-- Categories | <code><nowiki>{{Single namespace|Template|This text is only displayed in the Template namespace}}</nowiki></code> | ||
{{Single namespace|Template|This text is only displayed in the Template namespace}} | |||
=== Incorrect namespace === | |||
<code><nowiki>{{Single namespace|Category|This text is only displayed in the Category namespace}}</nowiki></code> | |||
<!--not using actual template because {{Incorrect namespace}} won't display in the Template namespace--> | |||
{{Mbox | type = content | image = [[File:Stop hand orange.svg|50px]] | text = {{Error|The above template should only be transcluded in the ''Category'' namespace(s).}} }} | |||
== See also == | |||
* [[Template:Category handler]] | |||
* [[Template:Incorrect namespace]] | |||
* [[Template:Namespace detect]] | |||
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox|| | |||
<!-- Categories here; interwikis in Wikidata --> | |||
[[Category:Template namespace templates]] | [[Category:Template namespace templates]] | ||
[[Category:Pages with templates in the wrong namespace| ]] | |||
</includeonly> | }}</includeonly> |
Revision as of 18:36, 7 December 2016
This is a documentation subpage for Template:Single namespace. It may contain usage information, categories and other content that is not part of the original template page. |
This template should not be substituted. |
Usage
This is a meta-template; it should only be used within other templates. It is used for namespace detection as a simplification of {{Foo other|Example|{{Incorrect namespace|foo}}}}
. If the template is transcluded in the Foo namespace, it will transclude "Example"; if not, it will transclude {{Incorrect namespace}}. Note that {{Incorrect namespace}} does not work in the template namespace.
The first parameter is necessary. It defines which namespace is the correct namespace for the template.
The second parameter is optional. It allows something (usually a category) to be transcluded in the correct namespace.
Examples
Correct namespace
{{Single namespace|Template|This text is only displayed in the Template namespace}}
This text is only displayed in the Template namespace
Incorrect namespace
{{Single namespace|Category|This text is only displayed in the Category namespace}}
The above template should only be transcluded in the Category namespace(s). |
See also