Template:Para/doc: Difference between revisions

From Linguifex
Jump to navigation Jump to search
(Created page with "{{Documentation subpage}} <!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE --> == Usage == This template is for giving examples of [[Wikipedia:Template me...")
 
No edit summary
Line 1: Line 1:
{{Documentation subpage}}
{{documentation subpage}}
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->


== Usage ==
== Usage ==
This template is for giving examples of [[Wikipedia:Template messages|template]] parameter source code (useful in template documentation and talk page discussions of template code).  It must have one or two parameters itself. The first is the name of the example parameter to display (this may be ''empty'', but it '''must''' be ''present''), and the second (optional) one is a value for the first example parameter, or (if the first {{tlx|para}} parameter is empty) an unnamed example parameter.
This template simply displays a parameter name between a vertical line and an equal sign, as is seen in [[wikt:Wiktionary:Templates|template]] calls. (This is useful in template documentation and in talk page discussions of templates.)
 
===Parameters===
This template takes the following parameters:
*{{para|1||''may be empty'' if second parameter is present}}: the name of the parameter
*{{para|2||''optional'' if first parameter is present}}: a corresponding value for the parameter
*{{para|3|opt=1}}: additional usage text
*{{para|req|1}}: indicate that the parameter is required
*{{para|opt|1}}: indicate that the parameter is optional


===Examples===
===Examples===
#&nbsp;&nbsp;{{tlx|para|name}}
# {{temp|para|name}}
#:renders as
#: Result: {{para|name}}
#:{{para|name}}
# {{temp|para|name|req=1}}
#&nbsp;&nbsp;{{tlx|para|title|&lt;var&gt;book title&lt;/var&gt;}}
#: Result: {{para|name|req=1}}
#:renders as
# {{temp|para|name|opt=1}}
#:{{para|title|<var>book title</var>}}
#: Result: {{para|name|opt=1}}
#&nbsp;&nbsp;{{tlx|para|3=section|2=<span style="font-size: 1pt;">&nbsp;</span>}}
# {{temp|para|opt|1}}
#:renders as
#: Result: {{para|opt|1}}
#:{{para||section}}
# {{temp|para|title|<nowiki><var>book title</var></nowiki>}}
#:(for unnamed parameters in the example code; note the empty first parameter in the {{tlx|para}} template)
#: Result: {{para|title|<var>book title</var>}}
#&nbsp;&nbsp;{{tlx|para|&lt;var&gt;parameter&lt;/var&gt;|&lt;var&gt;value&lt;/var&gt;}}
# {{temp|para||section}}
#:renders as
#: Result: {{para||section}}. This is useful for referring to values of unnamed parameters; note the empty first parameter in the template call.
#:{{para|<var>parameter</var>|<var>value</var>}}
# {{temp|para|<nowiki><var>parameter</var></nowiki>|<nowiki><var>value</var></nowiki>}}
 
#: Result: {{para|<var>parameter</var>|<var>value</var>}}
When using literal, pre-specified values, simply provide the value (appearance as in example 3). When illustrating hypothetical, variable or user-definable values, use <tt><nowiki><var>value</var></nowiki></tt> (appearance as in example 2), and the same should be done for non-literal, example parameters (as in example 4).
# {{temp|para|=&#124;foo}}
#: Result: {{para|=|foo}}
# {{temp|para|2||<nowiki>''optional'' if first parameter is present</nowiki>}}
#: Result: {{para|2||''optional'' if first parameter is present}}


When using literal, pre-specified values, simply provide the value (appearance as in example 6). When illustrating hypothetical, variable or user-definable values, use <code>&lt;var>value&lt;/var></code> (appearance as in example 5), and the same should be done for non-literal, example parameters (as in example 7).
== See also ==
== See also ==
* [[Template:Tlx]] &ndash; for providing examples of entire-template code with included parameters
* [[Template:tlx]] &ndash; for providing examples of entire-template code with included parameters
<noinclude>
<noinclude>[[Category:Templates]][[Category:Template documentation]]</noinclude>
[[Category:Templates]][[Category:Template documentation]]</noinclude>

Revision as of 11:56, 18 June 2023

Usage

This template simply displays a parameter name between a vertical line and an equal sign, as is seen in template calls. (This is useful in template documentation and in talk page discussions of templates.)

Parameters

This template takes the following parameters:

  • |1= (may be empty if second parameter is present): the name of the parameter
  • |2= (optional if first parameter is present): a corresponding value for the parameter
  • |3= (optional): additional usage text
  • |req=1: indicate that the parameter is required
  • |opt=1: indicate that the parameter is optional

Examples

  1. {{para|name}}
    Result: |name=
  2. {{para|name|req=1}}
    Result: |name= (required)
  3. {{para|name|opt=1}}
    Result: |name= (optional)
  4. {{para|opt|1}}
    Result: |opt=1
  5. {{para|title|<var>book title</var>}}
    Result: |title=book title
  6. {{para||section}}
    Result: |section. This is useful for referring to values of unnamed parameters; note the empty first parameter in the template call.
  7. {{para|<var>parameter</var>|<var>value</var>}}
    Result: |parameter=value
  8. {{para|=|foo}}
    Result: |=foo
  9. {{para|2||''optional'' if first parameter is present}}
    Result: |2= (optional if first parameter is present)

When using literal, pre-specified values, simply provide the value (appearance as in example 6). When illustrating hypothetical, variable or user-definable values, use <var>value</var> (appearance as in example 5), and the same should be done for non-literal, example parameters (as in example 7).

See also

  • Template:tlx – for providing examples of entire-template code with included parameters