Module:ParameterCount/doc

This module counts the number of parameters that are passed to a template. For example, you might put the code  inside the   template. If you then use  like this:

Then the  code inside the template will give the result.

This module can be configured to count all parameters, or specific parameters defined by a template author. This module is only useful in templates. It should not be used on non-template pages.

The module has two functions available,  and.

all
The  function is used to count all parameters specified when using a template, regardless of whether or not they are used in the template itself.

Usage

Examples

If the code  was added to the   template, the code   would make ParameterCount produce.

main
The  function is used to count parameters with specific names. There are two ways of specifying parameters: by name, and using Lua patterns.

By name

To specify a parameter by name, add the parameter name as a positional parameter.

By pattern

To specify parameters by Lua Ustring pattern, add the pattern to pattern1, pattern2 etc. For information on constructing Lua patterns, see the Lua Users' Wiki pattern tutorial, as well as the Lua reference manual sections on Lua patterns and Ustring patterns.

Examples

If the code  was added to the   template, the code   would make ParameterCount produce.

If the code  was added to the   template, the code   would make ParameterCount produce.

Checking for blanks
By default, the module doesn't count parameters whose values contain only whitespace, e.g. abc. If you wish to count all parameters, regardless of their value, use no. This works with both the  and   functions.

Examples

If the code  was added to the   template, the code   would make ParameterCount produce.