Template:Category handler/doc: Difference between revisions
No edit summary |
update dochead |
||
| Line 1: | Line 1: | ||
{{dochead}} | {{dochead|header=metatemplate}} | ||
{{Template rating|details=Currently in-progress and used for [[Template:Template rating]]. This may be tested on other categorizing templates to determine whether any changes should be made.}} | {{Template rating|details=Currently in-progress and used for [[Template:Template rating]]. This may be tested on other categorizing templates to determine whether any changes should be made.}} | ||
{{clear}} | {{clear}} | ||
Revision as of 10:04, 23 October 2025
- This template is a metatemplate. It is used to build other templates and should not be used standalone, except for testing or simple usage. This template is implemented by the Lua module Module:Category handler.
- This template invokes the following functions: category_handler from Category handler.
| This documentation is for a draft template. It is incomplete and may not be in active development. If possible, editors are encouraged to help with its development. In the meantime, editors should avoid using this template across the Xenharmonic Wiki, except for testing.
Details: Currently in-progress and used for Template:Template rating. This may be tested on other categorizing templates to determine whether any changes should be made. |
| This template has been deprecated. Its replacements are Template:Dochead and Template:Module introspection. |
| This template uses Lua: |
Template:Category handler is intended as a metatemplate that helps templates categorize pages. It also suppresses categories depending on the namespace or subpage.
Usage
Categories are entered as unnamed parameters, as shown.
{{Category handler | cat 1 | cat 2 | cat 3 }}
For example, the code below
{{Category handler | Abstract MOS patterns | 8-tone scales}}
categorizes the page under the following categories.
[[Category:Abstract MOS patterns]][[Category:8-tone scales]]
For testing purposes, categories can be turned off by adding debug=1. Modifying the previous example
{{Category handler | Abstract MOS patterns | 8-tone scales | debug=1 }}
disables categories.
Typically, this template is used as part of another template, so use something like debug={{{debug|}}}, so that debug=1 can be added to an instance of that template.
Category suppression
By default, this metatemplate allows categories within the following namespaces: main, file, mediawiki, template, category, and module. Templates placed within those namespaces will not categorize those pages.
This metatemplate is meant primarily for templates used within those namespaces. Use of this metatemplate is not required for templates with basic categorizing rules, or templates meant to be placed within other namespaces such as the user namespace.
Alternatively, this template can be adjusted to allow or disallow suppression in different namespaces. The example below allows a template to add categories a page within the user namespace, but not templates or modules. Namespaces are delimited using either newlines or semicolons.
{{category handler | allowed_ns = user | suppressed_ns = template; module}}
Additionally, this metatemplate suppresses categories if the page has the following suffixes (subpages): doc or sandbox. This prevents templates from categorizing test or documentation pages, but not if the /doc page is transcluded. This means categorizing templates that categorize other templates will the template's main page, but not their /doc subpages. However, if a categorizing template's documentation is demonstrating its own use, this isn't enough, so adding debug=1 is required to keep categorizing templates from erroneously categorizing themselves.