Content deleted Content added
Use {{tj}} when showing template examples |
→with_name_not_matching: Expand doc |
||
Line 263:
<syntaxhighlight lang="wikitext">{{#invoke:params|with_name_not_matching|n$|count}}</syntaxhighlight>
It is possible to use this function to check for unknown parameters:
<syntaxhighlight lang="wikitext">{{#ifexpr:{{#invoke:params|with_name_not_matching|^hello$|with_name_not_matching|^wind$|count}} > 0
|{{#invoke:Error|error|Error: The only parameters accepted are {{para|hello}} and {{para|wind}}.}}
|Everything is good: do something
}}</syntaxhighlight>
For simple cases like this, however, specialized modules are available; you might want to have a look at:
* {{ml|Check for unknown parameters|check}}
* {{ml|Check for deprecated parameters|check}}
* {{ml|Check for clobbered parameters|check}}
* {{ml|Parameter validation}}
* {{ml|TemplatePar}}
{{A note}} The argument passed to this function is not trimmed of its leading and trailing spaces. The <code>with_name_not_matching</code> function name itself, however, can be surrounded by spaces.
|