Template:Parameter names example/doc: Difference between revisions

From HIBIKIFORUM
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{Documentation subpage}}
{{Documentation subpage}}
{{template rating|p}}
{{Lua|Module:Parameter names example}}
{{tsh|Pnex}}


{{tl|Parameter names example}} is intended to assist [[Wikipedia:Template documentation|template documentation]] by producing a generic instance of the template that uses parameters' names as those parameters' values.
{{tl|Parameter names example}} is intended to assist [[Wikipedia:Template documentation|template documentation]] by producing a generic instance of the template that uses parameters' names as those parameters' values.
Line 12: Line 13:
<pre style="overflow:auto;">
<pre style="overflow:auto;">
{{Parameter names example
{{Parameter names example
|_template=Infobox
  |_template=Infobox
|title |above |subheader |subheader2 |image |caption  
  |title |above |subheader |subheader2 |image |caption  
|header1 |label2 |data2 |label3 |data3 |header4  
  |header1 |label2 |data2 |label3 |data3 |header4  
|data5 |data6 |below
  |data5 |data6 |below
}}
}}
</pre>
</pre>


==Usage notes==
== Usage notes ==
When <code><nowiki>{{Parameter names example}}</nowiki></code> is used on an immediate subpage of its target template&nbsp;– e.g. on the target template's /doc page&nbsp;– its own <code>|_template</code> parameter identifying the target template may be omitted. In other words, the code above, if used on Template:Infobox/''page'' (where ''page'' could be "doc", "testcases", etc.), would become:
When {{tlf|Parameter names example}} is used on an immediate subpage of its target template&nbsp;– e.g. on the target template's /doc page&nbsp;– its own {{para|_template}} parameter identifying the target template may be omitted. In other words, the code above, if used on Template:Infobox/''page'' (where ''page'' could be "doc", "testcases", etc.), would become:


<pre style="overflow:auto;">
<pre style="overflow:auto;">
{{Parameter names example
{{Parameter names example
|title |above |subheader |subheader2 |image |caption  
  |title |above |subheader |subheader2 |image |caption  
|header1 |label2 |data2 |label3 |data3 |header4  
  |header1 |label2 |data2 |label3 |data3 |header4  
|data5 |data6 |below
  |data5 |data6 |below
}}
}}
</pre>
</pre>


One exception to this is the "sandbox" subpage. If the module is called from a page ending in "/sandbox", it uses that page to generate the template output, not the base page. To override this behaviour you can specify the <code>|_template</code> parameter explicitly.
One exception to this is the "sandbox" subpage. If the module is called from a page ending in "/sandbox", it uses that page to generate the template output, not the base page. To override this behaviour you can specify the {{para|_template}} parameter explicitly.


The formatting of the parameter names can be changed with the <code>|_display</code> parameter. By default, the parameter names are shown in triple braces (the parameter standard, e.g. {{{name}}}{{{thin space}}}), but if <code>|_display|italics</code> or <code>|_display|italic</code> is set, they are shown in italics.
The formatting of the parameter names can be changed with the {{para|_display}} parameter. By default, the parameter names are shown in triple braces (the [[mw:Help:Templates#Parameters|parameter standard]], e.g. {{{name}}}), but if {{para|_display|italics}} or {{para|_display|italic}} is set, they are shown in italics.


A custom value for a parameter may be supplied by using <code>|[parameter name]|[value]</code> in place of <code>|[parameter name]</code>. Any formatting for such a value&nbsp;– including, for instance, italics&nbsp;– must be supplied as part of the value (e.g. <code>{{|parameter|<nowiki>''value''<br/></nowiki>}}</code>). Custom values cannot be used for parameters whose names begin with an underscore ("_").
A custom value for a parameter may be supplied by using {{para|[parameter name]|[value]}} in place of <code>|[parameter name]</code>. Any formatting for such a value&nbsp;– including, for instance, italics&nbsp;– must be supplied as part of the value (e.g. {{para|parameter|<nowiki>''value''<br/></nowiki>}}). Custom values cannot be used for parameters whose names begin with an underscore ("_").
 
<includeonly>{{sandbox other||{{testcases other||


<includeonly>
<!-- Categories below this line, please -->
<!-- Categories below this line, please -->
[[Category:Templates]]
[[Category:Utility templates]]
</includeonly>
}}}}</includeonly>

Latest revision as of 01:48, 20 August 2023

Light bulb.png }}
It contains usage information, categories and other content that is not part of the original template page.

{{Parameter names example}} is intended to assist template documentation by producing a generic instance of the template that uses parameters' names as those parameters' values.

Example

The example opposite for {{Infobox}}, for instance, was produced by:

{{{title}}}
{{{above}}}
{{{subheader}}}
{{{subheader2}}}
{{{image}}}
{{{caption}}}
{{{header1}}}
{{{label2}}}{{{data2}}}
{{{label3}}}{{{data3}}}
{{{header4}}}
{{{data5}}}
{{{data6}}}
{{{below}}}
{{Parameter names example
  |_template=Infobox
  |title |above |subheader |subheader2 |image |caption 
  |header1 |label2 |data2 |label3 |data3 |header4 
  |data5 |data6 |below
}}

Usage notes

When {{Parameter names example}} is used on an immediate subpage of its target template – e.g. on the target template's /doc page – its own |_template= parameter identifying the target template may be omitted. In other words, the code above, if used on Template:Infobox/page (where page could be "doc", "testcases", etc.), would become:

{{Parameter names example
  |title |above |subheader |subheader2 |image |caption 
  |header1 |label2 |data2 |label3 |data3 |header4 
  |data5 |data6 |below
}}

One exception to this is the "sandbox" subpage. If the module is called from a page ending in "/sandbox", it uses that page to generate the template output, not the base page. To override this behaviour you can specify the |_template= parameter explicitly.

The formatting of the parameter names can be changed with the |_display= parameter. By default, the parameter names are shown in triple braces (the parameter standard, e.g. {{{name}}}), but if |_display=italics or |_display=italic is set, they are shown in italics.

A custom value for a parameter may be supplied by using |[parameter name]=[value] in place of |[parameter name]. Any formatting for such a value – including, for instance, italics – must be supplied as part of the value (e.g. |parameter=''value''<br/>). Custom values cannot be used for parameters whose names begin with an underscore ("_").