Module:Template invocation/doc: रिवीजन सभ के बीचा में अंतर

विकिपीडिया से
Content deleted Content added
छो २ revisions imported from en:Module:Template_invocation/doc
छो Bot: Replace deprecated <source> tag and "enclose" parameter [https://lists.wikimedia.org/pipermail/wikitech-ambassadors/2020-April/002284.html]
 
लाइन 5: लाइन 5:
First load the module:
First load the module:


<source lang="lua">
<syntaxhighlight lang="lua">
local mTemplateInvocation = require('Module:Template invocation')
local mTemplateInvocation = require('Module:Template invocation')
</syntaxhighlight>
</source>


Then you can use the individual functions as documented below.
Then you can use the individual functions as documented below.
लाइन 13: लाइन 13:
=== Name ===
=== Name ===


<source lang="lua">
<syntaxhighlight lang="lua">
mTemplateInvocation.name(title)
mTemplateInvocation.name(title)
</syntaxhighlight>
</source>


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. <var>title</var> can be a string or a [[mw:Extension:Scribunto/Lua reference manual#Title objects|mw.title object]]. {{red|If <var>title</var> is a string, a mw.title object is created for it, which is [[WP:EXPENSIVE|expensive]].}}
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. <var>title</var> can be a string or a [[mw:Extension:Scribunto/Lua reference manual#Title objects|mw.title object]]. {{red|If <var>title</var> is a string, a mw.title object is created for it, which is [[WP:EXPENSIVE|expensive]].}}
लाइन 21: लाइन 21:
=== Invocation ===
=== Invocation ===


<source lang="lua">
<syntaxhighlight lang="lua">
mTemplateInvocation.invocation(name, args, format)
mTemplateInvocation.invocation(name, args, format)
</syntaxhighlight>
</source>


This function creates a MediaWiki [[Help:Template|template]] invocation.
This function creates a MediaWiki [[Help:Template|template]] invocation.

17:09, 22 अप्रैल 2020 ले भइल नया बदलाव

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

Usage[संपादन करीं]

First load the module:

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

Then you can use the individual functions as documented below.

Name[संपादन करीं]

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. If title is a string, a mw.title object is created for it, which is expensive.

Invocation[संपादन करीं]

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}}.