Module:Template invocation/doc

This is a meta-module for producing MediaWiki template invocations.

Usage
First load the module:

&#x3c;syntaxhighlight lang="lua"&#x3e; local mTemplateInvocation = require('Module:Template invocation') &#x3c;/syntaxhighlight&#x3e;

Then you can use the individual functions as documented below.

Name
&#x3c;syntaxhighlight lang="lua"&#x3e; mTemplateInvocation.name(title) &#x3c;/syntaxhighlight&#x3e;

This function produces the name to be used in a template invocation. For pages in the template namespace it returns the page name with no namespace prefix, for pages in the main namespace it returns the full page name prefixed with ":", and for other pages it returns the full page name. &#x3c;var&#x3e;title&#x3c;/var&#x3e; can be a string or a mw.title object.

Invocation
&#x3c;syntaxhighlight lang="lua"&#x3e; mTemplateInvocation.invocation(name, args, format) &#x3c;/syntaxhighlight&#x3e;

This function creates a MediaWiki template invocation.

Parameters:
 * name - the name of the template (string, required). This should be exactly as it will appear in the invocation, e.g. for Template:Example use "Example". To generate the template name from a page name you can use the name function.
 * args - the arguments to use in the invocation (table, required). Table keys and values must be either strings or numbers.
 * format - the format of the invocation (string, optional). The default is a normal invocation with unescaped curly braces, pipes, and equals signs. If this parameter is the string "nowiki", then the curly braces, pipes and equals signs are replaced with the appropriate HTML entities.

Example

The code mTemplateInvocation.invocation('foo', {'bar', 'baz', abc = 'def'}) would produce &#x3c;code&#x3e;&#x3c;nowiki&#x3e;&#x3c;/nowiki&#x3e;&#x3c;/code&#x3e;.

&#x3c;includeonly&#x3e;&#x3c;/includeonly&#x3e;