Content deleted Content added
No edit summary Tags: Reverted Mobile edit Mobile web edit |
m Reverted edits by 201.162.168.35 (talk) (HG) (3.4.13) |
||
(8 intermediate revisions by 8 users not shown) | |||
Line 5:
'''Module:Check for unknown parameters''' is used to check for uses of unknown parameters in a template or module. It may be appended to a template at the end or called directly from a module.
== Usage ==
=== From a template ===
To sort entries into a tracking category by parameter, use:
* {{mlx|Check for unknown parameters|check|unknown{{=}}<nowiki>[</nowiki>[Category:Some tracking category|_VALUE_]]|arg1|arg2|arg3|argN}}
To sort the entries into a tracking category by parameter with a preview error message, use:
* {{mlx|Check for unknown parameters|check|unknown{{=}}<nowiki>[</nowiki>[Category:Some tracking category|_VALUE_]]|preview{{=}}unknown parameter "_VALUE_"|arg1|arg2|...|argN}}
For an explicit red error message, use:
* {{mlx|Check for unknown parameters|check|unknown{{=}}<span class{{=}}"error">Sorry, I don't recognize _VALUE_</span>|arg1|arg2|...|argN}}
To use Lua patterns, use:
* {{mlx|Check for unknown parameters|check|unknown{{=}}<nowiki>[</nowiki>[Category:Some tracking category|_VALUE_]]|preview{{=}}unknown parameter "_VALUE_"|arg1|arg2|...|argN|regexp1{{=}}header[%d]+|regexp2{{=}}date[1-9]}}
===From a module===
To call from a module, use:
<syntaxhighlight lang="lua">
local checkForUnknownParameters = require("Module:Check for unknown parameters")
local result = checkForUnknownParameters._check(validArgs, args)
</syntaxhighlight>
Where the first set of args are the module args below and the second set of args are the parameters that are checked.
== Parameters ==
Line 10 ⟶ 33:
* Unnamed (positional) parameters can be added too: <code>|1|2|arg1|arg2|...</code>.
* [[:mw:Extension:Scribunto/Lua reference manual#Patterns|Lua patterns]] (similar to [[regular expression]]s) usage with parameters is also supported (such as: {{para|regexp1|header[%d]+}}, {{para|regexp2|date[1-9]}}, {{para|regexp3|data[%d]+[abc]?}}). This is useful when there are many known parameters which use a systematic pattern.
* {{para|unknown}} – what happens when an
* {{para|preview}} – the text to be displayed when in preview mode and an unknown parameter is used.
* The <code>_VALUE_</code> 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.
|