Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikibooksThe Free Textbook Project
Search

Module:Check for unknown parameters/doc

From Wikibooks, open books for an open world
<Module:Check for unknown parameters
This page may need to bereviewed for quality.
WarningThis Lua module is used inMediaWiki:Abusefilter-warning-DS, and onapproximately 13,500,000 pages, or roughly 4590% of all pages.
Changes to it can cause immediate changes to the Wikibooks user interface.
To avoid major disruption and server load, any changes should be tested in the module's/sandbox or/testcases subpages, or in your ownmodule sandbox. The tested changes can be added to this page in a single edit. Please discuss changes on thetalk page before implementing them.
This module depends on the following other modules:

This module may be appended to a template to check for uses of unknown parameters. Unlike many other modules, this module isnot implemented by a template.

Usage

[edit source]

Basic usage

[edit source]
{{#invoke:check for unknown parameters|check|unknown=[[Category:Some tracking category]]|arg1|arg2|arg3|argN}}

or to sort the entries in the tracking category by parameter with a preview error message

{{#invoke:check for unknown parameters|check|unknown=[[Category:Some tracking category|_VALUE_]]|preview=unknown parameter "_VALUE_"|arg1|arg2|...|argN}}

or for an explicit red error message

{{#invoke:check for unknown parameters|check|unknown=<span>Sorry, I don't recognize _VALUE_</span>|arg1|arg2|...|argN}}

Here,arg1,arg2, ...,argN, are the known parameters. Unnamed (positional) parameters can be added too:|1|2|argname1|argname2|.... Any parameter which is used, but not on this list, will cause the module to return whatever is passed with theunknown parameter. The_VALUE_ keyword, if used, will be changed to the name of the parameter. This is useful for either sorting the entries in a tracking category, or for provide more explicit information.

By default, the module makes no distinction between a defined-but-blank parameter and a non-blank parameter. That is, both unlisted|foo=x and|foo= are reported. To only track non-blank parameters use|ignoreblank=1.

By default, the module ignores blank positional parameters. That is, an unlisted|2= is ignored. Toinclude blank positional parameters in the tracking use|showblankpositional=1.

Lua patterns

[edit source]

This module supportsLua patterns (similar toregular expressions), which are useful when there are many known parameters which use a systematic pattern. For example,template:infobox3cols uses

| regexp1 = header[%d][%d]*| regexp2 = label[%d][%d]*| regexp3 = data[%d][%d]*[abc]?| regexp4 = class[%d][%d]*[abc]?| regexp5 = rowclass[%d][%d]*| regexp6 = rowstyle[%d][%d]*| regexp7 = rowcellstyle[%d][%d]*

to match all parameters of the formheaderNUM,labelNUM,dataNUM,dataNUMa,dataNUMb,dataNUMc, ...,rowcellstyleNUM, where NUM is a string of digits.

Example

[edit source]
{{Infobox| above = {{{name|}}}| label1 = Height| data1 = {{{height|}}}| label2 = Weight| data2 = {{{weight|}}}| label3 = Website| data3 = {{{website|}}}}}<!--   end infobox, start tracking-->{{#invoke:Check for unknown parameters|check| unknown = {{main other|[[Category:Some tracking category|_VALUE_]]}}| preview = unknown parameter "_VALUE_"| name| height | weight| website}}

Call from within Lua code

[edit source]

See the end ofModule:Rugby box for a simple example orModule:Infobox3cols orModule:Flag for more complicated examples.

See also

[edit source]


This is adocumentationsubpage forModule:Check for unknown parameters
It may contain usage information,categories, and other content that is not part of the original module page.
Retrieved from "https://en.wikibooks.org/w/index.php?title=Module:Check_for_unknown_parameters/doc&oldid=4248682"

[8]ページ先頭

©2009-2025 Movatter.jp