Importer, Bürokraten, Moderatoren (CommentStreams), Strukturierte-Diskussionen-Bots, Oberflächenadministratoren, Push-Abonnementverwalter, Oversighter, Administratoren, Kampagnenbearbeiter (Hochladeassistent)
855
Bearbeitungen
(Add tfm tag for new module merge) |
K (22 Versionen von wpen:Module:Labelled_list_hatnote/doc importiert) |
||
| (15 dazwischenliegende Versionen von 12 Benutzern werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
{{module rating|protected}} | {{module rating|protected}} | ||
{{ | {{used in system|in [[MediaWiki:Wantedpages-summary]]}} | ||
{{ | {{Lua|Module:Hatnote|Module:Hatnote list|Module:Arguments}} | ||
This module provides a handful of functions that make it easy to implement hatnotes that take the form of a label in front of a list of pages, e.g. {{hatnote|LABEL: [[A]], [[B]], and [[C]]}} | This module provides a handful of functions that make it easy to implement hatnotes that take the form of a label in front of a list of pages, e.g. {{hatnote|LABEL: [[A]], [[B]], and [[C]]}} | ||
== Usage == | == Usage == | ||
| Zeile 19: | Zeile 17: | ||
For example, providing "See also" instead of "Universal label" duplicates the functionality of {{tl|see also}}, while providing "Main article" and "Main articles" instead of "Singular label" and "Plural label" duplicates the (article namespace) functionality of {{tl|main}}. | For example, providing "See also" instead of "Universal label" duplicates the functionality of {{tl|see also}}, while providing "Main article" and "Main articles" instead of "Singular label" and "Plural label" duplicates the (article namespace) functionality of {{tl|main}}. | ||
If third and fourth labels are provided, they'll be used in the case where any of the target pages are outside the article namespace, so e.g. {{tl|main}} can be implemented thus: | |||
<code><nowiki>{{#invoke:Labelled list hatnote|labelledList|Main article|Main articles|Main page|Main pages}}</nowiki></code> | |||
===preprocessDisplays=== | ===preprocessDisplays=== | ||
The <code>preprocessDisplays()</code> function takes a raw list of arguments and combines in any display arguments. For example, {{tlx|see also|1|<nowiki>l1=One</nowiki>}} initially has the arguments table <code><nowiki>{'1', ['l1'] = 'One'}</nowiki></code>; this table would combine those into the table <code><nowiki>{'1|One'}</nowiki></code>. It overrides manual piping (e.g. {{tlx|see also|<nowiki>1{{!}}2</nowiki>|<nowiki>l1=One</nowiki>}} → <code><nowiki>{'1|One'}</nowiki></code>) and compresses sparse arrays if a parameter is skipped or left empty. | The <code>preprocessDisplays()</code> function takes a raw list of arguments and combines in any display arguments. For example, {{tlx|see also|1|<nowiki>l1=One</nowiki>}} initially has the arguments table <code><nowiki>{'1', ['l1'] = 'One'}</nowiki></code>; this table would combine those into the table <code><nowiki>{'1|One'}</nowiki></code>. It overrides manual piping (e.g. {{tlx|see also|<nowiki>1{{!}}2</nowiki>|<nowiki>l1=One</nowiki>}} → <code><nowiki>{'1|One'}</nowiki></code>) and compresses sparse arrays if a parameter is skipped or left empty. | ||
Example: < | Example: <syntaxhighlight lang="lua"> | ||
local mLabelledList = require('Module:Labelled list hatnote') | local mLabelledList = require('Module:Labelled list hatnote') | ||
local pages = mLabelledList.preprocessDisplays(args) | local pages = mLabelledList.preprocessDisplays(args) | ||
</ | </syntaxhighlight> | ||
===_labelledList=== | ===_labelledList=== | ||
| Zeile 37: | Zeile 39: | ||
#* a <code>selfref</code> string (or nil) as taken by <code>_hatnote</code> to enable the selfref option | #* a <code>selfref</code> string (or nil) as taken by <code>_hatnote</code> to enable the selfref option | ||
Example: < | Example: <syntaxhighlight lang="lua"> | ||
local mLabelledList = require('Module:Labelled list hatnote') | local mLabelledList = require('Module:Labelled list hatnote') | ||
return mLabelledList._labelledList(pages, labels, options) | return mLabelledList._labelledList(pages, labels, options) | ||
</ | </syntaxhighlight> | ||
==Errors== | ==Errors== | ||