close
Sayahna Sayahna
Search

Difference between revisions of "Template:Namespace detect"


(switch to Lua implementation)
m
Line 1: Line 1:
{{#invoke:Namespace detect|main}}<noinclude>
+
{{#switch:
 +
  {{lc:              <!--Lower case the result-->
 +
    <!--If no or empty "demospace" parameter then detect namespace-->
 +
    {{#if:{{{demospace|}}}
 +
    | {{{demospace}}}
 +
    | {{#if:{{{specificpage|}}}
 +
      | <!--Detect the namespace in the "specific page" parameter-->
 +
        {{#ifeq:{{NAMESPACE:{{{specificpage}}} }}|{{TALKSPACE:{{{specificpage}}} }}
 +
        | talk
 +
        | {{SUBJECTSPACE:{{{specificpage}}} }}
 +
        }}
 +
      | <!--No "demospace" or "specific page" parameters, so detect actual namespace-->
 +
        {{#ifeq:{{NAMESPACE}}|{{TALKSPACE}}
 +
        | talk
 +
        | {{SUBJECTSPACE}}
 +
        }}
 +
      }}
 +
    }}
 +
  }}
 +
<!-- Only one of the lines below will be executed -->
 +
<!-- Respecting empty parameters on purpose -->
 +
| main       <!--"demospace=main" or {{SUBJECTSPACE}}={{ns:0}}=""-->
 +
|              = {{{main| {{{other|}}} }}}
 +
| talk        = {{{talk| {{{other|}}} }}}
 +
| user        = {{{user| {{{other|}}} }}}
 +
| wikisource  = {{{wikisource| {{{other|}}} }}}
 +
| author      = {{{author| {{{other|}}} }}}
 +
| index        = {{{index| {{{other|}}} }}}
 +
| page        = {{{page| {{{other|}}} }}}
 +
| file
 +
| image        = {{{file| {{{image| {{{other|}}} }}} }}}
 +
| mediawiki    = {{{mediawiki| {{{other|}}} }}}
 +
| module      = {{{module| {{{other|}}} }}}
 +
| template    = {{{template| {{{other|}}} }}}
 +
| help        = {{{help| {{{other|}}} }}}
 +
| category    = {{{category| {{{other|}}} }}}
 +
| portal      = {{{portal| {{{other|}}} }}}
 +
| translation  = {{{translation| {{{other|}}} }}}
 +
| book        = {{{book| {{{other|}}} }}}
 +
| other
 +
| #default  = {{{other|}}}   <!--"demospace=other" or a new namespace-->
  
 +
}}<!--End switch--><noinclude>
 
{{documentation}}
 
{{documentation}}
<!-- Categories go on the /doc subpage, and interwikis go on Wikidata. -->
+
<!-- Add categories and interwikis to the /doc subpage, not here! -->
 
</noinclude>
 
</noinclude>

Revision as of 22:59, 6 July 2013

Documentation icon Template documentation[create]