Hello, you have come here looking for the meaning of the word
Module:template parser/documentation. In DICTIOUS you will not only get to know all the dictionary meanings for the word
Module:template parser/documentation, but we will also tell you about its etymology, its characteristics and you will know how to say
Module:template parser/documentation in singular and plural. Everything you need to know about the word
Module:template parser/documentation you have here. The definition of the word
Module:template parser/documentation will help you to be more precise and correct when speaking or writing your texts. Knowing the definition of
Module:template parser/documentation, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.
This module provides functions for parsing and finding template invocations found in wikitext.
parseTemplate(text, not_transcluded)
- 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 correctly parse any wikitext given as template arguments (such as subtemplates, arguments, tables etc), but if the string does not form a valid template in markup, then it will return
nil
.
findTemplates(text, not_transcluded)
- Finds all template invocations in the text. This is designed to be used as an iterator in for statements, and returns four values for each invocation:
- The template name.
- The template arguments.
- The full template invocation as it appears in the original text.
- The index the template appears at within the given text; as with Lua in general, the beginning of the text is index 1.
For convenience, template names will be normalized in two ways:
- They are preprocessed, which means that any templates (
{{ }}
) and parameters ({{{ }}}
) they contain will be resolved.
- Any redirects will be converted to their canonical equivalents (e.g.
{{l}}
is treated as {{link}}
).
Note that any templates with invalid names (after preprocessing) will be skipped over. For performance reasons, preprocessing is only applied to the keys in a template's table of arguments, so it should be applied (selectively) to the values by the calling module when needed.
Note that the parser will respect <noinclude>
, <includeonly>
and <onlyinclude>
tags. By default, text is treated as though it has been transcluded, which means that text between <noinclude>
tags will be ignored, and <onlyinclude>
tags will be respected if present. If the parameter not_transcluded is set to true
, then text will be treated as though it has not been transcluded, which means text between <includeonly>
tags will be ignored instead.
Although the parser is very accurate, some discrepancies may still exist between it and the native parser in certain cases.