Modul:Labelled list hatnote/doc: Unterschied zwischen den Versionen

K
22 Versionen von wpen:Module:Labelled_list_hatnote/doc importiert
(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}}
{{high-risk|154,000+}}
{{used in system|in [[MediaWiki:Wantedpages-summary]]}}
{{replace|{{replace|{{Tfm/dated|page={{PAGENAME}}|otherpage=Distinguish|link=Wikipedia:Templates for discussion/Log/2018 June 25#Module:Labelled list hatnote|bigbox=yes}}|template|module}}|Template:|Module:|count=1}}
{{Lua|Module:Hatnote|Module:Hatnote list|Module:Arguments}}
{{replace|{{replace|{{Tfm/dated|page={{PAGENAME}}|otherpage=About-distinguish|link=Wikipedia:Templates for discussion/Log/2018 June 25#Module:Labelled list hatnote|bigbox=yes}}|template|module}}|Template:|Module:|count=1}}  
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->


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: <source lang="lua">
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)
</source>
</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: <source lang="lua">
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)
</source>
</syntaxhighlight>


==Errors==
==Errors==