Jump to content

Module:templateparser/documentation

Wiktionary වෙතින්
Comment මෙම මොඩියුලය ඉංග්‍රිසි ව්‍යාපෘතියේ ආකාරයට Module:template parser වෙතට ගෙන ගොස් ඇත.

This module provides functions for parsing and finding template invocations found in wikitext.

parseTemplate(text)
Parses text as a template invocation and returns a pair of values, the template name and the arguments (containing anonymous, numbered and named arguments). If the text could not be parsed as a template invocation, the function returns nil. The parser will try to correctly parse subtemplates and tables when given as template parameters, but will throw an error if it detects invalid markup.
findTemplates(text)
Finds all template invocations in the text. This is designed to be used as an iterator in for statements, and returns six or seven values for each invocation:
  1. The template name.
  2. The template arguments (as in parseTemplate).
  3. The the full template invocation as it appears in the original text.
  4. The index the template appears at within the given text; as with Lua in general, the beginning of the text is index 1.
  5. subst, safesubst or transclude, depending on whether the template has been substituted, safe substituted or trancluded.
  6. template, module or parser function, depending on what the template is.
  7. If a module, the name of the function.

Since the parser is not perfect, it should never be used to audit code.


"https://si.wiktionary.org/w/index.php?title=Module:templateparser/documentation&oldid=165700" වෙතින් සම්ප්‍රවේශනය කෙරිණි