Jump to content
Toggle menu
  • 8 articles
  • 75 files
  • 7 users
  • 37.8K edits
Neodyland Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Template invocation/doc: Difference between revisions

From Neodyland Wiki
No edit summary
m 12 revisions imported
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This is a meta-module for producing MediaWiki template invocations.
This is a meta-module for producing MediaWiki template invocations.


{{High-use|demo=Module:Unsubst|2=yes}}
{{High-use}}


{{Module rating|template-protected}}
{{Module rating|p}}


== Usage ==
== Usage ==


First load the module:
First, load the module:


<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 32: Line 32:


Parameters:
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|name]] function.
* '''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|name]] function.
* '''args''' - the arguments to use in the invocation (table, required). Table keys and values must be either strings or numbers.
* '''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]].
* '''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'''
'''Example'''


The code {{code|1=mTemplateInvocation.invocation('foo', {'bar', 'baz', abc = 'def'})|2=lua}} would produce <code><nowiki>{{foo|bar|baz|abc=def}}</nowiki></code>.
The code {{code|1=mTemplateInvocation.invocation('foo', {'bar', 'baz', abc = 'def'})|2=lua}} would produce <code><nowiki>{{foo|bar|baz |abc=def}}</nowiki></code>.


<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||

Latest revision as of 16:09, 12 August 2026

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

This template is being used in the wrong namespace. Use {{Heavily used module}} instead!

Usage

edit

First, load the module:

local mTemplateInvocation = require('Module:Template invocation')

Then you can use the individual functions as documented below.

Name

edit
mTemplateInvocation.name(title)

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. title can be a string or a mw.title object.

Invocation

edit
mTemplateInvocation.invocation(name, args, format)

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 {{foo|bar|baz |abc=def}}.


Contents
Cookies help us deliver our services. By using our services, you agree to our use of cookies.