Editing
Module:Labelled list hatnote/doc
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{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]]}} == Usage == ===labelledList=== Invoking the <code>labelledList()</code> function is enough to implement most such templates: <code><nowiki>{{#invoke:Labelled list hatnote|labelledList|Universal label}}</nowiki></code> or <code><nowiki>{{#invoke:Labelled list hatnote|labelledList|Singular label|Plural label}}</nowiki></code> 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=== 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: <syntaxhighlight lang="lua"> local mLabelledList = require('Module:Labelled list hatnote') local pages = mLabelledList.preprocessDisplays(args) </syntaxhighlight> ===_labelledList=== For modules that need to modify the functionality slightly while still using it, <code>_labelledList()</code> provides some flexibility. It takes three parameters: # A pages list, preferably preprocessed and compressed by <code>preprocessDisplays</code> # A labels table, where the first item is the singular or universal label, and the second either a plural label or a copy of the first. # An options table, preferably containing: #* a <code>template</code> string with the full title of the template. Defaults to the title of this module. #* a <code>category</code> string (or nil) as taken by <code>makeWikitextError</code> from [[Module:Hatnote]], to optionally disable error categories #* a <code>selfref</code> string (or nil) as taken by <code>_hatnote</code> to enable the selfref option Example: <syntaxhighlight lang="lua"> local mLabelledList = require('Module:Labelled list hatnote') return mLabelledList._labelledList(pages, labels, options) </syntaxhighlight> ==Errors== This module causes templates based on it to produce an error message if no page names are provided as template parameters. Normally, these should lead back to "Errors" sections in the documentation of those templates. However, if those templates use a module with <code>_labelledList()</code> and don't provide a <code>template</code> item in their options table, that error defaults to leading back here. The error can be solved by providing at least one valid page-name parameter to the template in question; the problem in the template can be fixed by providing some value to the <code>template</code> item of the <code>_labelledList()</code> <code>options</code> table. <includeonly>{{sandbox other|| <!-- Categories below this line, please; interwikis at Wikidata --> [[Category:Hatnote modules| ]] }}</includeonly>
Summary:
Please note that all contributions to Mirrorplay: Fae are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
MPFae:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Module
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information