Misplaced Pages

Module:Template wrapper/doc: Difference between revisions

Article snapshot taken from[REDACTED] with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
< Module:Template wrapper Browse history interactively← Previous editContent deleted Content addedVisualWikitext
Revision as of 12:20, 21 November 2018 editTrappist the monk (talk | contribs)Administrators480,243 editsm Debugging aid: ce;← Previous edit Latest revision as of 07:17, 31 December 2024 edit undoNardog (talk | contribs)Edit filter helpers, Autopatrolled, Extended confirmed users, New page reviewers, Pending changes reviewers, Rollbackers, Template editors82,660 edits _ is stripped 
(16 intermediate revisions by 9 users not shown)
Line 1: Line 1:
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see ]) --> <!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see ]) -->


{{high-use}}
This module is to be used in wrapper templates to allow those templates to provide default parameter values and allow editors to pass additional parameters to the underlying working template.

: ''See also: {{mfl|params|concat_and_call}}''

This module is to be used in ] to allow those templates to provide default parameter values and allow editors to pass additional parameters to the underlying working template.


When writing a wrapper template, give this module all of the normally required default parameters necessary to use the wrapper template in its base form. Editors then use the wrapper template as-is or may supply additional wrapper and canonical parameters. Any of the canonical parameters supported by the working template may be added to the wrapper template or supplied by editors in article space. When an editor supplies a parameter that has a default value in the wrapper template, the editor-supplied value overrides the default. When it is necessary to remove a default parameter, editors may set the parameter value to the special keyword <code>unset</code> which will cause this wrapper module to erase the wrapper template's default value for that parameter. This module discards empty named parameters. When writing a wrapper template, give this module all of the normally required default parameters necessary to use the wrapper template in its base form. Editors then use the wrapper template as-is or may supply additional wrapper and canonical parameters. Any of the canonical parameters supported by the working template may be added to the wrapper template or supplied by editors in article space. When an editor supplies a parameter that has a default value in the wrapper template, the editor-supplied value overrides the default. When it is necessary to remove a default parameter, editors may set the parameter value to the special keyword <code>unset</code> which will cause this wrapper module to erase the wrapper template's default value for that parameter. This module discards empty named parameters.
Line 14: Line 18:


;Control parameters ;Control parameters
:{{para|_template}} – (required) the name, without namespace, of the working template (the template that is wrapped); see §] below :{{para|_template}} – (required) the name, without namespace, of the working template (the template that is wrapped); see §] below
:{{para|_exclude}} – comma-separated list of parameter names used by the wrapper template that are not to be passed to the working template; see §] below :{{para|_exclude}} – comma-separated list of parameter names used by the wrapper template that are not to be passed to the working template; see §] below
:{{para|_reuse}} – comma-separated list of canonical names that have meaning to both the wrapper template and to the working template; see §] below :{{para|_reuse}} – comma-separated list of canonical names that have meaning to both the wrapper template and to the working template; see §] below
:{{para|_alias-map}} – comma-separated list of wrapper-template parameter names that are to be treated as aliases of specified working template canonical parameters; see §] below :{{para|_alias-map}} – comma-separated list of wrapper-template parameter names that are to be treated as aliases of specified working template canonical parameters; see §] below
:{{para|_include-positional}} – pass all positional parameters to the working template; see §] below :{{para|_include-positional}} – pass all positional parameters to the working template; see §] below


;Definitions ;Definitions
Line 35: Line 39:
| style="border: 1px solid black;"|{{para|plain=yes|{{var|wrapper parameters}}}}||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp; | style="border: 1px solid black;"|{{para|plain=yes|{{var|wrapper parameters}}}}||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;
|- |-
|&nbsp;|| || style="border: 1px solid black;"|{{para|plain=yes|]}}||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||&nbsp;→&nbsp; |&nbsp;|| || style="border: 1px solid black;"|{{para|plain=yes|]}}||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||&nbsp;→&nbsp;
|- |-
|&nbsp;|| || style="border: 1px solid black;"|{{para|plain=yes|]}}||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp; |&nbsp;|| || style="border: 1px solid black;"|{{para|plain=yes|]}}||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;
|- |-
|&nbsp;|| || style="border: 1px solid black;"|{{para|plain=yes|]}}||&nbsp;→&nbsp;||style="border: 2px solid black;" rowspan="3"|convert alias<br />parameters to<br />canonical<br />parameters||&nbsp;→&nbsp;||style="border: 1px solid black;" rowspan="2"|{{para|plain=yes|{{var|canonical parameters}}}}||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;|| ||&nbsp;→&nbsp; |&nbsp;|| || style="border: 1px solid black;"|{{para|plain=yes|]}}||&nbsp;→&nbsp;||style="border: 2px solid black;" rowspan="3"|convert alias<br />parameters to<br />canonical<br />parameters||&nbsp;→&nbsp;||style="border: 1px solid black;" rowspan="2"|{{para|plain=yes|{{var|canonical parameters}}}}||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;|| ||&nbsp;→&nbsp;
|- |-
|&nbsp;|| || || ||&nbsp;→&nbsp;||&nbsp;→&nbsp;||style="border: 2px solid black;" rowspan="4"|modify<br />reused<br />canonical<br />parameters |&nbsp;|| || || ||&nbsp;→&nbsp;||&nbsp;→&nbsp;||style="border: 2px solid black;" rowspan="4"|modify<br />reused<br />canonical<br />parameters
Line 45: Line 49:
| style="border: 1px solid black;"|{{para|plain=yes|{{var|alias parameters}}}}||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;|| || || ||&nbsp;→&nbsp;||style="border: 1px solid black;"|{{para|plain=yes|{{var|reused parameters}}}}||&nbsp;→&nbsp;||style="text-align: center;"|–––→||&nbsp;→&nbsp; | style="border: 1px solid black;"|{{para|plain=yes|{{var|alias parameters}}}}||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;|| || || ||&nbsp;→&nbsp;||style="border: 1px solid black;"|{{para|plain=yes|{{var|reused parameters}}}}||&nbsp;→&nbsp;||style="text-align: center;"|–––→||&nbsp;→&nbsp;
|- |-
|&nbsp;|| || style="border: 1px solid black;"|{{para|plain=yes|]}}||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp; |&nbsp;|| || style="border: 1px solid black;"|{{para|plain=yes|]}}||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;
|- |-
| style="border: 1px solid black;"|{{para|plain=yes|{{var|canonical parameters}}}}||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp; | style="border: 1px solid black;"|{{para|plain=yes|{{var|canonical parameters}}}}||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;||style="text-align: center;"|–––––––→||&nbsp;→&nbsp;
Line 58: Line 62:


===_alias-map=== ===_alias-map===
{{para|alias-map}} takes a comma-separated list of wrapper-template parameters that are to be treated as aliases of specified working template canonical parameters. Each mapping element of the list has the form: {{para|_alias-map}} takes a comma-separated list of wrapper-template parameters that are to be treated as aliases of specified working template canonical parameters. Each mapping element of the list has the form:
:<code>&lt;{{var|from}}>:&lt;{{var|to}}></code> – where: <code>&lt;{{var|from}}></code> is a wrapper parameter name and <code>&lt;{{var|to}}></code> is a canonical parameter name :<code>&lt;{{var|from}}>:&lt;{{var|to}}></code> – where: <code>&lt;{{var|from}}></code> is a wrapper parameter name and <code>&lt;{{var|to}}></code> is a canonical parameter name
In this example, it may be preferable for a wrapper template to use {{para|assessor}} which may be unknown to the working template but the working template may have an equivalent {{para|author}} so in the <code><nowiki>{{#invoke:}}</nowiki></code> we would write: In this example, it may be preferable for a wrapper template to use {{para|assessor}} which may be unknown to the working template but the working template may have an equivalent {{para|author}} so in the <code><nowiki>{{#invoke:}}</nowiki></code> we would write:
Line 73: Line 77:


===_reuse=== ===_reuse===
{{para|_reuse}} takes a comma-separated list of canonical parameters that have meaning to both the wrapper template and to the working template {{para|_reuse}} takes a comma-separated list of canonical parameters that have meaning to both the wrapper template and to the working template; not supported for positional parameters.


In the simplest cases, a canonical parameter passed into the wrapper template overrides a default parameter provided in the wrapper template. Sometimes a wrapper parameter is the same as a canonical parameter and the wrapper template needs to modify the parameter value before it is passed to the working template. In this example, {{para|title}} is both a wrapper parameter and a canonical parameter that the wrapper template needs to modify before passing to the working template. To do this we first write: In the simplest cases, a canonical parameter passed into the wrapper template overrides a default parameter provided in the wrapper template. Sometimes a wrapper parameter is the same as a canonical parameter and the wrapper template needs to modify the parameter value before it is passed to the working template. In this example, {{para|title}} is both a wrapper parameter and a canonical parameter that the wrapper template needs to modify before passing to the working template. To do this we first write:
:{{para|_reuse|title}} :{{para|_reuse|title}}
then, in the wrapper template's <code><nowiki>{{#invoke:Template wapper|wrap|_template=...|...}}</nowiki></code> we write: then, in the wrapper template's <code><nowiki>{{#invoke:Template wrapper|wrap|_template=...|...}}</nowiki></code> we write:
:{{para|title|Modified <nowiki>{{{title}}}</nowiki>}} :{{para|title|Modified <nowiki>{{{title}}}</nowiki>}}


Line 87: Line 91:
As an example, a wrapper template might use {{para|id}} to supply a portion of the value assigned to default parameter {{para|url}} so we would write: As an example, a wrapper template might use {{para|id}} to supply a portion of the value assigned to default parameter {{para|url}} so we would write:
:{{para|_exclude|id}} :{{para|_exclude|id}}
then, in the wrapper template's <code><nowiki>{{#invoke:Template wapper|wrap|_template=...|...}}</nowiki></code> we write: then, in the wrapper template's <code><nowiki>{{#invoke:Template wrapper|wrap|_template=...|...}}</nowiki></code> we write:
:{{para|url|<nowiki>https://example.com/{{{id}}}</nowiki>}} :{{para|url|<nowiki>https://example.com/{{{id}}}</nowiki>}}
The modified {{para|url}} value is passed on to working template but {{para|id}} and its value is not. The modified {{para|url}} value is passed on to working template but {{para|id}} and its value is not.
Line 96: Line 100:
{{para|_include-positional}} is a boolean parameter that takes only one value: <code>yes</code>; the default (empty, missing) is <code>no</code> (positional parameters normally excluded). When set to <code>yes</code>, Module:Template wrapper will pass all positional parameters to the working template. {{para|_include-positional}} is a boolean parameter that takes only one value: <code>yes</code>; the default (empty, missing) is <code>no</code> (positional parameters normally excluded). When set to <code>yes</code>, Module:Template wrapper will pass all positional parameters to the working template.


See also §]. See also §].


===Overriding default parameters=== ===Overriding default parameters===
Line 103: Line 107:
_reused parameters cannot be <code>unset</code> or overridden. _reused parameters cannot be <code>unset</code> or overridden.


==Debugging aid== ==Debugging/documentation mode==
This module has two entry points. A wrapper template might use a module <code><nowiki>{{#invoke:}}</nowiki></code> written like this: This module has two entry points. A wrapper template might use a module <code><nowiki>{{#invoke:}}</nowiki></code> written like this:
:<code><nowiki>{{#invoke:</nowiki>{{BASEPAGENAME}}|<nowiki>{{#if:{{{_debug|}}}|list|wrap}}</nowiki>|_template=<{{var|working template}}>|_exclude=_debug, ...|...}}</code> :<code><nowiki>{{#invoke:</nowiki>{{BASEPAGENAME}}|<nowiki>{{#if:{{{_debug|}}}|list|wrap}}</nowiki>|_template=<{{var|working template}}>|_exclude=_debug, ...|...}}</code>
where the {{para|_debug}} wrapper parameter, set to any value, will cause the module to render the call to the working template without actually calling the working template. where the {{para|_debug}} wrapper parameter, set to any value, will cause the module to render the call to the working template without actually calling the working template.


As an example, {{tlx|cite wikisource/sandbox}} is a wrapper template that uses {{tlx|citation}} as its working template. {{tld|cite wikisource/sandbox}} accepts positional parameters but {{tld|citation}} does not so the wrapper template must convert the positional parameters to named parameters which it does using the {{para|_alias-map}} parameter: As an example, {{tlx|cite wikisource}} is a wrapper template that uses {{tlx|citation}} as its working template. {{tld|cite wikisource}} accepts positional parameters but {{tld|citation}} does not so the wrapper template must convert the positional parameters to named parameters which it does using the {{para|_alias-map}} parameter:
:<syntaxhighlight lang="moin">{{#invoke:template wrapper|{{#if:{{{_debug|}}}|list|wrap}}|_template=citation/new :<syntaxhighlight lang="wikitext">{{#invoke:template wrapper|{{#if:{{{_debug|}}}|list|wrap}}|_template=citation
|_exclude=..., _debug <!-- unnecessary detail omitted --> |_exclude=..., _debug <!-- unnecessary detail omitted -->
|_alias-map=1:title, 2:author, 3:language</syntaxhighlight> |_alias-map=1:title, 2:author, 3:language</syntaxhighlight>
This example uses positional parameters and sets {{para|_debug|yes}} to show that the {{tld|citation}} template is correctly formed: This example uses positional parameters and sets {{para|_debug|yes}} to show that the {{tld|citation}} template is correctly formed:
:<code><nowiki>{{cite wikisource/sandbox|Sentido y sensibilidad|Jane Austen|es|_debug=yes}}</nowiki></code> :<code><nowiki>{{cite wikisource|Sentido y sensibilidad|Jane Austen|es|_debug=yes}}</nowiki></code>
::{{cite wikisource/sandbox|Sentido y sensibilidad|Jane Austen|es|_debug=yes}} ::{{cite wikisource|Sentido y sensibilidad|Jane Austen|es|_debug=yes}}
and, with {{para|_debug}} unset: and, with {{para|_debug}} unset:
:<code><nowiki>{{cite wikisource/sandbox|Sentido y sensibilidad|Jane Austen|es|_debug=}}</nowiki></code> :<code><nowiki>{{cite wikisource|Sentido y sensibilidad|Jane Austen|es|_debug=}}</nowiki></code>
::{{cite wikisource/sandbox|Sentido y sensibilidad|Jane Austen|es|_debug=}} ::{{cite wikisource|Sentido y sensibilidad|Jane Austen|es|_debug=}}
The {{para|_debug}} name is chosen here for convenience but may be anything so long as it matches the <code><nowiki>{{#if:}}</nowiki></code> in the <code><nowiki>{{#invoke:}}</nowiki></code>. The {{para|_debug}} name is chosen here for convenience but may be anything so long as it matches the <code><nowiki>{{#if:}}</nowiki></code> in the <code><nowiki>{{#invoke:}}</nowiki></code>.

You may also call the <code>link</code> function to get something like the left-hand side of ]. This is essentially the <code>list</code> function with the template name turned into a link.
{{yytop|headers=no}}
{{yy|User in New Zealand|4}}
{{yybottom}}

<includeonly>{{sandbox other|| <includeonly>{{sandbox other||
<!-- Categories below this line, please; interwikis at Wikidata --> <!-- Categories below this line, please; interwikis at Wikidata -->
]

}}</includeonly> }}</includeonly>

Latest revision as of 07:17, 31 December 2024


WarningThis Lua module is used on approximately 680,000 pages, or roughly 1% of all pages.
To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them.
See also: {{#invoke:params|concat_and_call}}

This module is to be used in wrapper templates to allow those templates to provide default parameter values and allow editors to pass additional parameters to the underlying working template.

When writing a wrapper template, give this module all of the normally required default parameters necessary to use the wrapper template in its base form. Editors then use the wrapper template as-is or may supply additional wrapper and canonical parameters. Any of the canonical parameters supported by the working template may be added to the wrapper template or supplied by editors in article space. When an editor supplies a parameter that has a default value in the wrapper template, the editor-supplied value overrides the default. When it is necessary to remove a default parameter, editors may set the parameter value to the special keyword unset which will cause this wrapper module to erase the wrapper template's default value for that parameter. This module discards empty named parameters.

Positional parameters are not normally passed on to the working template. Setting |_include-positional=yes will pass all positional parameters to the working template. Positional parameters cannot be excluded; positional parameters may be unset.

Parameters that are used only by the wrapper should be either positional ({{{n}}}) or listed in |_exclude= (a comma-separated list of named parameters). This module will not pass _excluded parameters to the working template.

Usage

{{#invoke:Template wrapper|wrap|_template=working template|_exclude=named parameter, named parameter, ...|_reuse=named parameter, named parameter, ...|_alias-map=alias parameter:canonical parameter|_include-positional=yes|<default parameter>|<default parameter>|...}}

Control parameters
|_template= – (required) the name, without namespace, of the working template (the template that is wrapped); see §_template below
|_exclude= – comma-separated list of parameter names used by the wrapper template that are not to be passed to the working template; see §_exclude below
|_reuse= – comma-separated list of canonical names that have meaning to both the wrapper template and to the working template; see §_reuse below
|_alias-map= – comma-separated list of wrapper-template parameter names that are to be treated as aliases of specified working template canonical parameters; see §_alias-map below
|_include-positional= – pass all positional parameters to the working template; see §_include-positional below
Definitions
canonical parameter – a parameter supported and used by the working template
wrapper parameter – a parameter used by the wrapper template; may provide data for canonical parameters or control other aspects of the wrapper template
alias parameter – a wrapper parameter that is contextually meaningful to the wrapper template but must be renamed to a canonical parameter for use by the working template
reused parameter – a parameter that is shared by both wrapper and working templates and has been modified by wrapper template
default parameter – a canonical parameter given a default value in the wrapper template
parameter processing
wrapper
template
Module:Template wrapper working
template
|canonical parameters=  →  –––––––→  →  –––––––→  →  –––––––→  →  –––––––→  →  –––––––→  →  filter
exclued
parameters
working
template
|wrapper parameters=  →  –––––––→  →  –––––––→  →  –––––––→  →  –––––––→  →  –––––––→  → 
  |_exclude=  →  –––––––→  →  –––––––→  →  –––––––→  →  –––––––→  →   → 
  |_include-positional=  →  –––––––→  →  –––––––→  →  –––––––→  →  –––––––→  → 
  |_alias-map=  →  convert alias
parameters to
canonical
parameters
 →  |canonical parameters=  →  –––––––→  →  –––––––→  →   → 
   →   →  modify
reused
canonical
parameters
|alias parameters=  →  –––––––→  →   →  |reused parameters=  →  –––→  → 
  |_reuse=  →  –––––––→  →  –––––––→  → 
|canonical parameters=  →  –––––––→  →  –––––––→  →  –––––––→  → 
  |default parameters=  →  –––––––→  →  –––––––→  →  –––––––→  →  –––––––→  →  –––→  → 

Parameter details

_template

The only required parameter, |_template= supplies the name, without namespace, of the working template (the template that is wrapped). If this parameter is omitted, Module:Template wrapper will emit the error message:

|_template= missing or empty

_alias-map

|_alias-map= takes a comma-separated list of wrapper-template parameters that are to be treated as aliases of specified working template canonical parameters. Each mapping element of the list has the form:

<from>:<to> – where: <from> is a wrapper parameter name and <to> is a canonical parameter name

In this example, it may be preferable for a wrapper template to use |assessor= which may be unknown to the working template but the working template may have an equivalent |author= so in the {{#invoke:}} we would write:

|_alias-map=assessor:author

Positional parameters may also be mapped to canonical parameters:

|_alias-map=1:author, 2:title, 3:language

Enumerated wrapper parameters may be mapped to enumerated canonical parameters using the # enumerator specifier:

|_alias-map=assessor#:author#

Given the above example, |assessor2= will map to |author2=; also, |assessor= and |assessor1= will map to |author1=

Multiple wrapper parameters can map to a single canonical parameter:

|_alias-map=1:author, assessor:author

Wrapper parameters listed in |alias-map= are not passed to the working template. Mapping positional parameters when |_include-positional=yes may give undesirable results. |_alias-map=1:author and |_include-positional=yes will cause all other positional parameters to be passed to the working template as is: wrapper template {{{2}}} becomes working template {{{2}}}, etc; working template will not get {{{1}}} though it will get |author=.

_reuse

|_reuse= takes a comma-separated list of canonical parameters that have meaning to both the wrapper template and to the working template; not supported for positional parameters.

In the simplest cases, a canonical parameter passed into the wrapper template overrides a default parameter provided in the wrapper template. Sometimes a wrapper parameter is the same as a canonical parameter and the wrapper template needs to modify the parameter value before it is passed to the working template. In this example, |title= is both a wrapper parameter and a canonical parameter that the wrapper template needs to modify before passing to the working template. To do this we first write:

|_reuse=title

then, in the wrapper template's {{#invoke:Template wrapper|wrap|_template=...|...}} we write:

|title=Modified {{{title}}}

_reused parameters cannot be overridden.

_exclude

|_exclude= takes a comma-separated list of parameters used by the wrapper template that are not to be passed to the working template. This list applies to all wrapper and canonical parameters (including those canonical parameters that are renamed alias parameters) received from the wrapper template.

As an example, a wrapper template might use |id= to supply a portion of the value assigned to default parameter |url= so we would write:

|_exclude=id

then, in the wrapper template's {{#invoke:Template wrapper|wrap|_template=...|...}} we write:

|url=https://example.com/{{{id}}}

The modified |url= value is passed on to working template but |id= and its value is not.

_reused and default parameters cannot be excluded.

_include-positional

|_include-positional= is a boolean parameter that takes only one value: yes; the default (empty, missing) is no (positional parameters normally excluded). When set to yes, Module:Template wrapper will pass all positional parameters to the working template.

See also §_alias-map.

Overriding default parameters

Editors may override default parameters by simply setting the default parameter to the desired value in the wrapper template. This module ignores empty parameters (those parameters that are named but which do not have an assigned value). When it is desirable to override a default parameter to no value, use the special keyword unset. Default parameters with this value are passed to the working template as empty (no assigned value) parameters.

_reused parameters cannot be unset or overridden.

Debugging/documentation mode

This module has two entry points. A wrapper template might use a module {{#invoke:}} written like this:

{{#invoke:Template wrapper|{{#if:{{{_debug|}}}|list|wrap}}|_template=<working template>|_exclude=_debug, ...|...}}

where the |_debug= wrapper parameter, set to any value, will cause the module to render the call to the working template without actually calling the working template.

As an example, {{cite wikisource}} is a wrapper template that uses {{citation}} as its working template. {{cite wikisource}} accepts positional parameters but {{citation}} does not so the wrapper template must convert the positional parameters to named parameters which it does using the |_alias-map= parameter:

{{#invoke:template wrapper|{{#if:{{{_debug|}}}|list|wrap}}|_template=citation
  |_exclude=..., _debug <!-- unnecessary detail omitted -->
  |_alias-map=1:title, 2:author, 3:language

This example uses positional parameters and sets |_debug=yes to show that the {{citation}} template is correctly formed:

{{cite wikisource|Sentido y sensibilidad|Jane Austen|es|_debug=yes}}
{{citation|author=Jane Austen|language=es|mode=cs1|title=]|via=]}}

and, with |_debug= unset:

{{cite wikisource|Sentido y sensibilidad|Jane Austen|es|_debug=}}
Jane Austen. Sentido y sensibilidad  (in Spanish) – via Wikisource.

The |_debug= name is chosen here for convenience but may be anything so long as it matches the {{#if:}} in the {{#invoke:}}.

You may also call the link function to get something like the left-hand side of Template:yy. This is essentially the list function with the template name turned into a link.

{{User in New Zealand|4}}
This user is a part-time resident of New Zealand.
linked pages


Module:Template wrapper/doc: Difference between revisions Add topic