Module:Template parameter value/doc

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

Module:Template parameter value/doc

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

Module functions

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 true and the contents of the requested parameter or false and a reason for failure.

The following options are available:

  • template_index: Which occurrence of the template to look for the parameter in. Set to -1 for last occurrence. (default: 1)
  • parameter_index: Which occurrence of the parameter to look for (default: 1; only applies when ignore_subtemplates 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 parameter_index (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 true and the text of the requested template or false and a reason for failure.

getTemplate supports the options template_index and treat_as_regex from getParameter.

Helper functions

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

Template functions

main implements {{Template parameter value}} and acts as a template wrapper for getParameter.

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

Testcases

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

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.