Module:Template parameter value/doc

Implements Template parameter value and HasTemplate, and can be used from other modules.

getParameter
getParameter takes 4 arguments: The page name (string), the template/s (string or table of strings), the parameter (string), and an optional options table. It will return either  and the contents of the requested parameter or   and a reason for failure.

The following options are available:
 * template_index: Which occurance of the template to look for the parameter in (default: 1)
 * parameter_index: Which occurance of the parameter to look for (default: 1; only applies when  is false)
 * ignore_subtemplates: If parameters should only be searched for in the top-level template, ignoring the parameters in subtemplates (default: false)
 * only_subtemplates: If parameters should only be searched for in subtemplates of the top-level template (default: false)
 * ignore_blank: Whether or not blank values should count towards  (default: false)
 * treat_as_regex: Whether or not the template string(s) should be treated as a lua regex (default: false)

getTemplate
getTemplate takes 3 arguments: The page name (string), the template/s (string or table of strings), and an optional options table. It will return either  and the text of the requested template or   and a reason for failure.

getTemplate supports the options  and   options from getParameter.

Helper functions
The module exposes some of the helper functions used (, , and  ) for convenience. Each function has some comments above it in the code explaining its rough purpose.

Template functions
implements Template parameter value and acts as a template wrapper for.

implements HasTemplate and somewhat acts as a wrapper for  (it only provides if the template was found, not the template text itself).

Testcases
Testcases are available at Module talk:Template parameter value/testcases