<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://moasspedia.org/w/index.php?action=history&amp;feed=atom&amp;title=Template%3AWhen_pagename_is%2Fdoc</id>
	<title>Template:When pagename is/doc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://moasspedia.org/w/index.php?action=history&amp;feed=atom&amp;title=Template%3AWhen_pagename_is%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://moasspedia.org/w/index.php?title=Template:When_pagename_is/doc&amp;action=history"/>
	<updated>2026-04-13T05:48:01Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.37.2</generator>
	<entry>
		<id>https://moasspedia.org/w/index.php?title=Template:When_pagename_is/doc&amp;diff=39203&amp;oldid=prev</id>
		<title>Wikipedia&gt;Izno: /* See also */ rm sect</title>
		<link rel="alternate" type="text/html" href="https://moasspedia.org/w/index.php?title=Template:When_pagename_is/doc&amp;diff=39203&amp;oldid=prev"/>
		<updated>2021-12-25T17:53:37Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;See also: &lt;/span&gt; rm sect&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Documentation subpage}}&lt;br /&gt;
&amp;lt;!--Categories where indicated at the bottom of this page, please; interwikis at Wikidata (see [[Wikipedia:Wikidata]])--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is the {{tl|When pagename is}} meta-template. It helps other templates detect what page they are on, using pattern matching on the pagename.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
This template takes one or more parameters. Most of the parameters don&amp;#039;t have fixed names, instead they are part of the pattern matching. Like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{When pagename is&lt;br /&gt;
| /doc = Doc page text&lt;br /&gt;
| other = Other pages text&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the template is on &amp;quot;Template:Example/doc&amp;quot; the code above will return this:&lt;br /&gt;
: {{When pagename is&lt;br /&gt;
  | /doc = Doc page text&lt;br /&gt;
  | other = Other pages text&lt;br /&gt;
  | page = Template:Example/doc&lt;br /&gt;
 }}&lt;br /&gt;
&lt;br /&gt;
If the template is on any &amp;#039;&amp;#039;other&amp;#039;&amp;#039; page than a /doc page it will return this:&lt;br /&gt;
&lt;br /&gt;
: {{When pagename is&lt;br /&gt;
   | /doc = Doc page text&lt;br /&gt;
   | other = Other pages text&lt;br /&gt;
   | page = Template:Example&lt;br /&gt;
  }}&lt;br /&gt;
&lt;br /&gt;
Here is a description of the full pattern matching:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{When pagename is&lt;br /&gt;
&amp;lt;!-- Match on full pagename --&amp;gt;&lt;br /&gt;
 | User:Example/test = Text for &amp;quot;User:Example/test&amp;quot;.&lt;br /&gt;
 | User:Example = Text for &amp;quot;User:Example&amp;quot;.&lt;br /&gt;
 | User talk:Example = Text for &amp;quot;User talk:Example&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Match on full basepage name, when on a basepage or its subpages --&amp;gt;&lt;br /&gt;
 | User:Example/+ = Matches &amp;quot;User:Example&amp;quot; and &amp;quot;User:Example/test&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Match on pagename, when on a basepage --&amp;gt;&lt;br /&gt;
 | Example = Matches &amp;quot;User:Example&amp;quot;, &amp;quot;User talk:Example&amp;quot;, &amp;quot;Template:Example&amp;quot; &lt;br /&gt;
             and so on, but not &amp;quot;User:Example/something&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Match on full basepage name, when on a subpage --&amp;gt;&lt;br /&gt;
 | User:Example/* = Matches &amp;quot;User:Example/something&amp;quot;, but not &amp;quot;User:Example&amp;quot;.&lt;br /&gt;
 | User talk:Example/* = Matches &amp;quot;User talk:Example/something&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Match on basepage name, when on a subpage --&amp;gt;&lt;br /&gt;
 | Example/* = Matches &amp;quot;User:Example/something&amp;quot; and &amp;quot;User talk:Example/something&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Match on subpage name --&amp;gt;&lt;br /&gt;
 | /something = Any pagename that ends in &amp;quot;/something&amp;quot;.&lt;br /&gt;
 | /doc = Any pagename that ends in &amp;quot;/doc&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Match on partial subpage name (case-insensitive) --&amp;gt;&lt;br /&gt;
 | /some* = Any subpage name beginning with &amp;quot;/some&amp;quot; or &amp;quot;/Some&amp;quot;.&lt;br /&gt;
 | /arch* = Matches &amp;quot;User talk:Example/Archive 1&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Defaults --&amp;gt;&lt;br /&gt;
 | basepage = Text for any basepage.&lt;br /&gt;
 | subpage = Text for any subpage.&lt;br /&gt;
 | other = Text for any page.&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The matching goes from top to bottom, and returns the first parameter that matches. &amp;quot;&amp;#039;&amp;#039;Top to bottom&amp;#039;&amp;#039;&amp;quot; means the order shown above, not the order you happen to feed the parameters.&lt;br /&gt;
&lt;br /&gt;
There&amp;#039;s no limit to the number of parameters that you can use, other than what the servers and MediaWiki system can handle. &lt;br /&gt;
&lt;br /&gt;
Most of the matching is case-sensitive. For instance &amp;quot;&amp;lt;code&amp;gt;/test&amp;lt;/code&amp;gt;&amp;quot; matches &amp;quot;User:Example/test&amp;quot; but not &amp;quot;User:Example/Test&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
Matching on partial subpage names such as &amp;quot;&amp;lt;code&amp;gt;/some*&amp;lt;/code&amp;gt;&amp;quot; has some limitations, see [[#Partial subpage names|its own section]] below.&lt;br /&gt;
&lt;br /&gt;
If an empty (but defined) parameter matches, the matching stops and the template returns an empty string. That&amp;#039;s on purpose and can be used like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{When pagename is&lt;br /&gt;
 | /doc =&lt;br /&gt;
 | /sandbox = Sandbox text&lt;br /&gt;
 | other = Other pages text&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code above will render nothing when on a /doc page. But when on a /sandbox page it will return this: &lt;br /&gt;
&lt;br /&gt;
: {{When pagename is&lt;br /&gt;
   | /doc =&lt;br /&gt;
   | /sandbox = Sandbox text&lt;br /&gt;
   | other = Other pages text&lt;br /&gt;
   | page = Template:Example/sandbox&lt;br /&gt;
  }}&lt;br /&gt;
&lt;br /&gt;
And when on any other page it will return this:&lt;br /&gt;
: {{When pagename is&lt;br /&gt;
   | /doc =&lt;br /&gt;
   | /sandbox = Sandbox text&lt;br /&gt;
   | other = Other pages text&lt;br /&gt;
   | page = Template:Example&lt;br /&gt;
  }}&lt;br /&gt;
&lt;br /&gt;
== Partial subpage names ==&lt;br /&gt;
&lt;br /&gt;
This template can also match on partial subpage names. Like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{When pagename is&lt;br /&gt;
 | /archiv* = Archive page text&lt;br /&gt;
 | other = Other pages text&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If on &amp;quot;User:Example/Archive 1&amp;quot; the code above will return this:&lt;br /&gt;
: {{When pagename is&lt;br /&gt;
   | /archiv* = Archive page text&lt;br /&gt;
   | other = Other pages text&lt;br /&gt;
   | page = User:Example/Archive 1&lt;br /&gt;
  }}&lt;br /&gt;
&lt;br /&gt;
The parameter name &amp;quot;&amp;lt;code&amp;gt;/some*&amp;lt;/code&amp;gt;&amp;quot; must be lower case. But it matches subpage names in both upper and lower case such as &amp;quot;User:Example/SomeThing&amp;quot; and &amp;quot;User:Example/something&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The partial matching only supports matching on 4, 6 and 8 characters. Thus using &amp;quot;&amp;lt;code&amp;gt;/some*&amp;lt;/code&amp;gt;&amp;quot;, &amp;quot;&amp;lt;code&amp;gt;/someth*&amp;lt;/code&amp;gt;&amp;quot; and &amp;quot;&amp;lt;code&amp;gt;/somethin*&amp;lt;/code&amp;gt;&amp;quot; works, but using &amp;quot;&amp;lt;code&amp;gt;/som*&amp;lt;/code&amp;gt;&amp;quot; or &amp;quot;&amp;lt;code&amp;gt;/somet*&amp;lt;/code&amp;gt;&amp;quot; doesn&amp;#039;t work.&lt;br /&gt;
&lt;br /&gt;
Longer patterns match first, thus if both &amp;quot;&amp;lt;code&amp;gt;/somethin*&amp;lt;/code&amp;gt;&amp;quot; and &amp;quot;&amp;lt;code&amp;gt;/some*&amp;lt;/code&amp;gt;&amp;quot; are defined, and the current page is &amp;quot;User:Example/Something&amp;quot;, then the data from &amp;quot;&amp;lt;code&amp;gt;/somethin*&amp;lt;/code&amp;gt;&amp;quot; will be used.&lt;br /&gt;
&lt;br /&gt;
== &amp;quot;page&amp;quot; parameter ==&lt;br /&gt;
&lt;br /&gt;
For testing and demonstration purposes this template can take a parameter named &amp;#039;&amp;#039;&amp;#039;page&amp;#039;&amp;#039;&amp;#039;. Like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{When pagename is&lt;br /&gt;
 | /test = Test pages text&lt;br /&gt;
 | other = Other pages text&lt;br /&gt;
 | page = Template:Example/test&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
No matter on what kind of page the code above is used it will return this:&lt;br /&gt;
: {{When pagename is&lt;br /&gt;
   | /test = Test pages text&lt;br /&gt;
   | other = Other pages text&lt;br /&gt;
   | page = Template:Example/test&lt;br /&gt;
  }}&lt;br /&gt;
&lt;br /&gt;
The &amp;#039;&amp;#039;&amp;#039;page&amp;#039;&amp;#039;&amp;#039; parameter makes this template behave exactly as if on that page. The pagename doesn&amp;#039;t have to be an existing page. &lt;br /&gt;
&lt;br /&gt;
If the &amp;#039;&amp;#039;&amp;#039;page&amp;#039;&amp;#039;&amp;#039; parameter is empty or undefined, the name of the current page determines the result.&lt;br /&gt;
&lt;br /&gt;
You can make it so your template also understands the &amp;#039;&amp;#039;&amp;#039;page&amp;#039;&amp;#039;&amp;#039; parameter. That means you can demonstrate the different appearances of your template in the documentation for your template. Then do like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{When pagename is&lt;br /&gt;
 | /test = Test pages text&lt;br /&gt;
 | other = Other pages text&lt;br /&gt;
 | page = {{{page|}}}&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Namespace matching ==&lt;br /&gt;
&lt;br /&gt;
This template doesn&amp;#039;t have namespace matching. If you need that then combine this template with one of the namespace-detection templates such as {{tl|When on template page}}. Like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{When on template page&lt;br /&gt;
 | {{When pagename is&lt;br /&gt;
    | /doc = Template doc page text.&lt;br /&gt;
   }}&lt;br /&gt;
 | &amp;lt;!--(action if not on a Template: page)--&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If on &amp;quot;User:Example/doc&amp;quot; the code above will return nothing. But if on &amp;quot;Template:Example/doc&amp;quot; it will return this:&lt;br /&gt;
: {{When on template page |demospace=template&lt;br /&gt;
   | {{When pagename is&lt;br /&gt;
      | /doc = Template doc page text.&lt;br /&gt;
      | page = Template:Example/doc&lt;br /&gt;
     }}&lt;br /&gt;
  | &amp;lt;!--(action if not on a Template: page)--&amp;gt;&lt;br /&gt;
 }}&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
&lt;br /&gt;
This template detects subpages even when used in namespaces that don&amp;#039;t have the MediaWiki [[meta:Link#Subpage feature|subpage feature]] enabled. Thus this template works the same in all namespaces.&lt;br /&gt;
&lt;br /&gt;
For more technical details, see the [[Template talk:When pagename is|talk page]].&lt;br /&gt;
&lt;br /&gt;
{{Namespace and pagename-detecting templates}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;includeonly&amp;gt;{{Sandbox other|&lt;br /&gt;
| &amp;lt;!--Categories below this line, please; interwikis at Wikidata--&amp;gt;&lt;br /&gt;
[[Category:If-then-else templates]]&lt;br /&gt;
[[Category:Pagename manipulation templates]]&lt;br /&gt;
[[Category:Wikipedia metatemplates]]&lt;br /&gt;
}}&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wikipedia&gt;Izno</name></author>
	</entry>
</feed>