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 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 or listed in (a comma-separated list of named parameters). This module will not pass _excluded
parameters to the working template.
<nowiki>{{#invoke:</nowiki>{{BASEPAGENAME}}|wrap|_template={{var|working template}}|_exclude={{var|named parameter}}, {{var|named parameter}}, ...|_reuse={{var|named parameter}}, {{var|named parameter}}, ...|_alias-map={{var|alias parameter}}:{{var|canonical parameter}}|_include-positional=yes|<{{var|default parameter}}>|<{{var|default parameter}}>|...}}
Module:Template wrapper ! | working template | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
→ | –––––––→ | → | –––––––→ | → | –––––––→ | → | –––––––→ | → | –––––––→ | → | filter exclued parameters | working template | ||
→ | –––––––→ | → | –––––––→ | → | –––––––→ | → | –––––––→ | → | –––––––→ | → | ||||
→ | –––––––→ | → | –––––––→ | → | –––––––→ | → | –––––––→ | → | → | |||||
→ | –––––––→ | → | –––––––→ | → | –––––––→ | → | –––––––→ | → | ||||||
→ | convert alias parameters to canonical parameters | → | → | –––––––→ | → | –––––––→ | → | → | ||||||
→ | → | modify reused canonical parameters | ||||||||||||
→ | –––––––→ | → | → | → | –––→ | → | ||||||||
→ | –––––––→ | → | –––––––→ | → | ||||||||||
→ | –––––––→ | → | –––––––→ | → | –––––––→ | → | ||||||||
→ | –––––––→ | → | –––––––→ | → | –––––––→ | → | –––––––→ | → | –––→ | → |
The only required parameter, 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 emptytakes 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:
<{{var|from}}>:<{{var|to}}>
– where: <{{var|from}}>
is a wrapper parameter name and <{{var|to}}>
is a canonical parameter nameIn this example, it may be preferable for a wrapper template to use which may be unknown to the working template but the working template may have an equivalent so in the <nowiki>{{#invoke:}}</nowiki>
we would write:
Positional parameters may also be mapped to canonical parameters:
Enumerated wrapper parameters may be mapped to enumerated canonical parameters using the #
enumerator specifier:
Given the above example, will map to ; also, and will map to
Multiple wrapper parameters can map to a single canonical parameter:
Wrapper parameters listed in are not passed to the working template. Mapping positional parameters when may give undesirable results. and will cause all other positional parameters to be passed to the working template as is: wrapper template <nowiki>{{{2}}}</nowiki>
becomes working template <nowiki>{{{2}}}</nowiki>
, etc; working template will not get <nowiki>{{{1}}}</nowiki>
though it will get .
takes a comma-separated list of canonical parameters that have meaning to both the wrapper template and to the working template
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, 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:
then, in the wrapper template's <nowiki>{{#invoke:Template wrapper|wrap|_template=...|...}}</nowiki>
we write: