Module:Params/doc/examples/check for unknown parameters: Difference between revisions
Appearance
Content deleted Content added
First draft Tag: Removed redirect |
Update |
||
Line 1: | Line 1: | ||
<includeonly>{{#ifexpr:{{#invoke:params|with_name_not_matching|hello| |
<includeonly>{{#ifexpr:{{#invoke:params|with_name_not_matching|hello|strict|with_name_not_matching|wind|strict|count}} > 0 |
||
|{{#invoke:Error|error|Error: The only parameters accepted are {{para|hello}} and {{para|wind}}.}} |
|{{#invoke:Error|error|Error: The only parameters accepted are {{para|hello}} and {{para|wind}}.}} |
||
|Everything is good: do something |
|Everything is good: do something |
Revision as of 09:04, 17 May 2024
This example template shows to use {{#invoke:params|discarding|...}} to check for unknown parameters.
Usage
For instance, writing
{{module:params/doc/examples/check for unknown parameters
| hello = world
| wind = surfing
}}
will generate
- Everything is good: do something
while writing
{{module:params/doc/examples/check for unknown parameters
| hello = world
| wind = surfing
| wrong = ups!
}}
will generate
- Error: The only parameters accepted are
|hello=
and|wind=
.
For simple cases like this specialized modules are available; you might want to have a look at:
- {{#invoke:Check for unknown parameters|check}}
- {{#invoke:Check for deprecated parameters|check}}
- {{#invoke:Check for clobbered parameters|check}}
- {{#invoke:Parameter validation|validateparams}}
- {{#invoke:TemplatePar|valid}}