Difference between revisions of "Module:Template wrapper/doc"

From blackwiki
Jump to navigation Jump to search
test>Pppery
test>Anthony Appleyard
m (Anthony Appleyard moved page Module:Citation/CS1/Wrapper/doc to Module:Template wrapper/doc: histmerge)
Line 1: Line 1:
<noinclude>{{histmerge|Module:Citation/CS1/Wrapper/doc}}</noinclude>
+
This module is to be used in cs1|2 wrapper templates to allow those templates to provide 'default' settings and at the same time allow editors to pass additional parameters to the underlying cs1|2 template.
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
 
== Usage ==
 
  
<code><nowiki>{{#invoke:</nowiki>{{BASEPAGENAME}}|wrap|_template={{var|wrapped template}}|_exclude={{var|named parameter}}, {{var|named parameter}}, ...}}</code>
+
This module requires one parameter: {{para|template}}, the name (without namespace) of the template that is wrapped.  {{tlx|cite Grove}} wraps {{tlx|cite encyclopedia}} so requires {{para|template|cite encyclopedia}}.
  
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 template.
+
When writing a wrapper template, give this module all of the normally required default parameters necessary to write the citation in its base form.  Editors then use the wrapper template as is or may supply additional cs1|2 parameters.  Any of the normal cs1|2 parameters supported by the wrapped 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 'unset' (make blank) 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.  Empty parameters convey no special meaning to cs1|2 templates so this module discards them.
  
This module requires one parameter: {{para|_template}}, the name (without namespace) of the template that is wrapped.
+
Certain cs1|2 parameters require the presence of other parameters.  For example, {{para|url-access|subscription}} requires {{para|url}}.  When a wrapper template does not specify {{para|url}} as a default but appropriate urls, when provided, are subscription-only, the wrapper template should test for the presence of a url and set {{para|url-access}} accordingly:
 +
:<code><nowiki>|url-access={{#if:{{{url|}}}|subscription}}</nowiki></code>
  
When writing a wrapper template, give this module all of the normally required default parameters necessary to use the template in its base form. Editors then use the wrapper template as is or may supply additional parameters. Any of the normal parameters supported by the wrapped 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 parameters.
+
Parameters to be used only by the wrapper should be either positional (<code><nowiki>{{{</nowiki>{{var|n}}}}}</code>) or prefixed with an underscore (<code><nowiki>{{{</nowiki>_{{var|name}}}}}</code>). This module will not pass these types of parameters to the wrapped template.
 
 
Parameters that are used only by the wrapper should be either positional ({{param|{{var|n}}}}) or listed in {{para|_exclude}} (a comma-separated list of named parameters). This module will not pass these types of parameters to the wrapped template.
 
 
 
<includeonly>{{sandbox other||
 
<!-- Categories below this line, please; interwikis at Wikidata -->
 
 
 
}}</includeonly>
 

Revision as of 21:00, 14 July 2018

This module is to be used in cs1|2 wrapper templates to allow those templates to provide 'default' settings and at the same time allow editors to pass additional parameters to the underlying cs1|2 template.

This module requires one parameter: |template=, the name (without namespace) of the template that is wrapped. {{cite Grove}} wraps {{cite encyclopedia}} so requires |template=cite encyclopedia.

When writing a wrapper template, give this module all of the normally required default parameters necessary to write the citation in its base form. Editors then use the wrapper template as is or may supply additional cs1|2 parameters. Any of the normal cs1|2 parameters supported by the wrapped 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 'unset' (make blank) 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. Empty parameters convey no special meaning to cs1|2 templates so this module discards them.

Certain cs1|2 parameters require the presence of other parameters. For example, |url-access=subscription requires |url=. When a wrapper template does not specify |url= as a default but appropriate urls, when provided, are subscription-only, the wrapper template should test for the presence of a url and set |url-access= accordingly:

|url-access={{#if:{{{url|}}}|subscription}}

Parameters to be used only by the wrapper should be either positional ({{{n}}}) or prefixed with an underscore ({{{_name}}}). This module will not pass these types of parameters to the wrapped template.