Implements {{Template parameter value}} and {{HasTemplate}}, and can be used from other modules.
| This Lua module is used on approximately 12,000,000 pages, or roughly 18% of all pages. To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them. |
| This module depends on the following other modules: |
Implements {{Template parameter value}} and {{HasTemplate}}, and can be used from other modules.
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:
ignore_subtemplates is false)parameter_index (default: false)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.
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.
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 are available at Module talk:Template parameter value/testcases
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.