Template:Defn/doc

From Official Kodi Wiki
< Template:Defn
Revision as of 13:08, 2 November 2021 by RogueScholar (talk | contribs) (Add TemplateData)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


1 Usage

The template {{Defn}} is used in template-structured glossaries and other lists which express correlated properties in pairs to show how something is defined. It is a wrapper for <dd>...</dd>, the description list definition HTML element.

Pro forma usage is thus:

{{glossary}}
{{term|1=term}}
{{defn|1=Definition.}}
{{glossary end}}

Links, inline templates, reference citations, wikimarkup styles, etc., can be applied to the definition. Technically, the |1= part is optional if the content of the definition does not contain the '=' character, but as any editors can add content, including templates with this character in them, it is always safest to explicitly name the parameter. The |1= parameter can also be called |defn= for those who don't care for unnamed or numeric parameters.

  • This will work: {{defn|1=The concept that the mass of a body is a measure of its energy content, expressed by the formula E=MC²}}
  • This will work: {{defn|defn=The concept that the mass of a body is a measure of its energy content, expressed by the formula E=MC²}}
  • This will fail: {{defn|The concept that the mass of a body is a measure of its energy content, expressed by the formula E=MC²}}

More complex usage might be:

{{defn|1=Definition. |num=# |term=term_id}}

where |num=# gives a leading number for a definition in a list of definitions, and |term=term_id provides the name of the term used in the {{term}} template to which this definition pertains.

1.1 Images, hatnotes and other content

Images, hatnotes and other "add-in" content intended to immediately follow the {{term}} must be used at the top of (inside) the first {{defn}} of the {{term}}. They cannot be placed between the {{term}} and {{defn}} or it will break the glossary markup. Images can, of course, be placed elsewhere within the {{defn}}, and bottom-notes like {{more}} can be placed at the ends of, but inside the content of {{defn}}s.

{{Glossary}}
{{Term |1=colour ball |content=colour ball {{Anchor|coloured ball|coloured balls|colour|colours|color ball}}}}
{{Defn|1=
[[File:Set of Snookerballs.png|thumb|right|150px|A complete set of snooker balls, with six '''colour balls''']]
<p class="glossary-hatnote"><span>Also '''coloured ball(s)''', '''colour(s)'''; American spelling '''color''' sometimes also used.</span></p>
In snooker, any of the object balls that are not reds.
}}
{{Glossary end}}
colour ball
A complete set of snooker balls, with six colour balls

Also coloured ball(s), colour(s); American spelling color sometimes also used.

In snooker, any of the object balls that are not reds.

1.2 Multiple definitions for one term

If a single {{term}} has multiple definitions, they are simply numbered with the |2=parameter explicitly. Think of the parameter as standing for "2nd or later definition". You can also call it |num=, if you prefer.

Example:

{{Glossary}}
{{Term|1=blubbermonster}}
{{Defn|1=Lorem ipsum dolor sit amet. |num=1}}
{{Defn|1=Consectetur adipisicing elit. |num=2}}
{{Glossary end}}
blubbermonster
1.  Lorem ipsum dolor sit amet.
2.  Consectetur adipisicing elit.

Because of the uneven length of definitions, it is usually more convenient to put the |2= before the |1= description:

{{defn |2=1 |1=Lorem ipsum dolor sit amet.}}

or

{{defn |num=1 |1=Lorem ipsum dolor sit amet.}}

This is a very robust method, because it permits complex content like block quotations, nested lists, cross-reference hatnotes, and other block-level markup inside each definition. The definitions can also be independently linked.

1.3 Making the definition independently linkable

HTML5 update:

Most of the restrictions on the content of id have been removed, so id values no longer have to begin with an [a-z][A-Z] alphabetic character, avoid most punctuation marks, or suffer other such limitations. The MediaWiki engine is smart enough to auto-escape any problematic characters, on the fly.

To enable a link directly to a specific definition, name the definition with its {{term}} (or it must be the |id=foo value, if any, used in {{term}}). This must be unique on the page for each term, but should be the same for multiple definitions of the same term). This is done with the {{defn}}'s |term= parameter. This will produce a #-link target ID in the form term-defn#, where the # is the number of the definition (see #Multiple definitions for one term, above), defaulting to "1".

Example:

{{Glossary}}
{{Term|1=blubbermonster}}
{{Defn|num=1 |1=Lorem ipsum dolor sit amet. |term=blubbermonster}}
{{Defn|num=2 |1=Consectetur adipisicing elit. |term=blubbermonster}}
{{Term|1=snorkelweasel (noun)}}
{{Defn|1=Ut enim ad minim veniam |term=snorkelweasel (noun)}}
{{Glossary end}}
blubbermonster
1.  Lorem ipsum dolor sit amet.
2.  Consectetur adipisicing elit.
snorkelweasel (noun)
Ut enim ad minim veniam
 HTML output:
<dl class="glossary">
  <dt class="glossary" id="blubbermonster" style="margin-top: 0.4em;"><dfn class="glossary">blubbermonster</dfn></dt>
  <dd class="glossary" id="blubbermonster-defn1">1.&nbsp;&nbsp;Lorem ipsum dolor sit amet.</dd>
  <dd class="glossary" id="blubbermonster-defn2">2.&nbsp;&nbsp;Consectetur adipisicing elit.</dd>
  <dt class="glossary" id="snorkelweasel_(noun)" style="margin-top: 0.4em;"><dfn class="glossary">snorkelweasel (noun)</dfn></dt>
  <dd class="glossary" id="snorkelweasel_(noun)-defn1">Ut enim ad minim veniam</dd>
</dl>

Note that some characters in snorkelweasel (noun)" have been converted on the fly by MediaWikia by the time it sends the ID to the browser as snorkelweasel_.28noun.29-defn1. You can still link to it on this page as #snorkelweasel (noun)-defn1 (view page source and see for yourself – that link has href=#snorkelweasel_.28noun.29-defn1).

The IDs blubbermonster-defn1, blubbermonster-defn2,  and snorkelweasel_(noun)-defn1 are all individually linkable, e.g. as [[Glossary of weird terms#blubbermonster-defn1]]. This is especially useful for cross-references within the glossary, e.g. See also [[#blubbermonster-defn2|"blubbermonster", sense 2]].

To add more than one linkable anchor, use the {{Anchor}} template at the beginning of the definition's content:

{{defn|num=2|1={{anchor|elit|Elit}}Consectetur adipisicing elit.|term=blubbermonster}}

1.4 Examples

This shows both a very simple then a rather complex instance:

<div style="color: #000000; background: none; overflow: hidden; page-break-after: avoid; font-size: 1.5em; font-family: Georgia,Times,serif; margin-top: 1em; margin-bottom: 0.25em; line-height: 1.3; padding: 0; border-bottom: 1px solid #AAAAAA;">A&ndash;M</div>
{{Glossary}}
{{Term|1=applesnorkel}}
{{Defn|1=Definition of term 1.}}
{{Term|term=arglefarst |content=''arglefarst''{{Anchor|argle-farst|argle farst}} }}
{{Defn|num=1 |defn=
Beginning of first definition of term 2
<blockquote style="margin-top: 0; margin-bottom: -0.5em;">Block quotation in first definition of term 2.</blockquote>
Conclusion of first definition of term 2.
}}
{{Defn|num=2 |defn=Second definition of term 2.}}
{{Glossary end}}
A–M
applesnorkel
Definition of term 1.
arglefarst
1.  Beginning of first definition of term 2

Block quotation in first definition of term 2.

Conclusion of first definition of term 2.
2.  Second definition of term 2.

1.5 Applying CSS styles to the definition

The |style= parameter will pass CSS styling on to the <dd> element, e.g. |style=font-family:serif; or whatever. I.e., this styles the definition itself, not the term it applies to, other definitions, or the glossary as a whole. This feature is rarely if ever needed in articles, but can be useful elsewhere for things like matching custom user page style.

1.6 Other parameters

The |id= parameter can be used to assign a one-word, case-sensitive ID name to definition. It must be unique on the page. This can be used as a #link target, and could have other metadata uses. See the #Making the definition independently linkable section for how to normally make a definition linkable. Probably the only reason to use this feature is if there are two terms with the same name on the page, which would result in conflicting IDs.

The |class= parameter will pass one or more space-separated CSS classes on to <dd> element, in addition to the automatically included class glossary. There is rarely any reason to do this.

2 TemplateData

This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools.

TemplateData for Defn

<templatedata>{

 "description": "This template is used to provide the definition text assigned to the preceding {{Term}} template within the context of a {{Glossary}} or HTML definition list.",
 "format: "inline",
 "paramOrder": [
   "2",
   "defn",
   "term",
   "id",
   "class",
   "style"
 ],
 "params": {
   "class": {
     "label": "CSS classes",
     "description": "Extra named CSS3 classes to assign to the definition, affecting its visual characteristics or layout on the page.",
     "type": "line",
     "required": false,
     "suggested": false,
     "deprecated": false,
     "aliases": []
   },
   "id": {
     "label": "Anchor name",
     "description": "Assigns a specific id to use as the definition's HTML anchor for hyperlinking elsewhere on the page or on other pages.",
     "type": "line",
     "required": false,
     "suggested": false,
     "deprecated": false,
     "aliases": []
   },
   "term": {
     "label": "List entry being defined",
     "description": "In the event of multiple definitions provided for a single list entry, this field should be set to match the preceding {{Term}} template."
     "type": "line",
     "required": false,
     "suggested": false,
     "deprecated": false,
     "aliases": []
   },
   "style": {
     "label": "CSS style declarations",
     "description": "Extra CSS3 style declarations to customize the visual appearance or layout of the definition on the page.",
     "type": "string",
     "required": false,
     "suggested": false,
     "deprecated": false,
     "aliases": []
   },
   "2": {
     "label": "Definition number",
     "description": "In the event of multiple definitions for a single list entry, this parameter assigns the sequence they should appear in using a single positive integer incremented by one.",
     "type": "number",
     "required": false,
     "suggested": false,
     "deprecated": false,
     "aliases": [
       "num"
     ]
   },
   "defn": {
     "label": "Definition",
     "description": "Definition text.",
     "type": "string",
     "required": true,
     "suggested": false,
     "deprecated": false,
     "aliases": [
       "1",
       "content"
     ]
   }
 }

}</templatedata>