Module:Hatnote/doc: Difference between revisions

Content deleted Content added
remove rellink, update hatnote, and update makeWikitextError
remove unnecessary underscores and fix one function name
Line 41:
 
<source lang="lua">
mHatnote._rellink_hatnote('This is a hatnote.', {extraclasses = 'boilerplate seealso', selfref = true})
</source>
 
Line 53:
 
<source lang="lua">
mHatnote._formatLinkformatLink(link, display)
</source>
 
Line 59:
 
;Examples:
: {{code|mHatnote._formatLinkformatLink('Lion')|lua}} &rarr; <nowiki>[[Lion]]</nowiki> &rarr; {{format hatnote link|Lion}}
: {{code|mHatnote._formatLinkformatLink('Lion#Etymology')|lua}} &rarr; <nowiki>[[Lion#Etymology|Lion § Etymology]]</nowiki> &rarr; {{format hatnote link|Lion#Etymology}}
: {{code|mHatnote._formatLinkformatLink('Category:Lions')|lua}} &rarr; <nowiki>[[:Category:Lions]]</nowiki> &rarr; {{format hatnote link|Category:Lions}}
: {{code|mHatnote._formatLinkformatLink('Lion#Etymology', 'Etymology of lion')|lua}} &rarr; <nowiki>[[Lion#Etymology|Etymology of lion]]</nowiki> &rarr; {{format hatnote link|Lion#Etymology|Etymology of lion}}
 
=== Format pages ===
 
<source lang="lua">
mHatnote._formatPagesformatPages(...)
</source>
 
Formats a list of pages using the [[#Format link|_formatLinkformatLink]] function, and returns the result as an array. For example, the code {{code|mHatnote._formatPagesformatPages('Lion', 'Category:Lions', 'Lion#Etymology')|lua}} would produce an array like {{code|{'[[Lion]]', '[[:Category:Lions]]', '[[Lion#Etymology|Lion § Etymology]]'}|lua}}.
 
=== Format page tables ===
 
<source lang="lua">
mHatnote._formatPageTablesformatPageTables(...)
</source>
 
Takes a list of page/display tables, formats them with the [[#Format link|_formatLinkformatLink]] function, and returns the result as an array. Each item in the list must be a table. The first value in the table is the link, and is required. The second value in the table is the display value, and is optional. For example, the code {{code|mHatnote._formatPagesformatPages({'Lion', 'the Lion article'}, {'Category:Lions'}, {'Lion#Etymology', 'the etymology of lion'})|lua}} would produce an array like {{code|{'[[Lion|the Lion article]]', '[[:Category:Lions]]', '[[Lion#Etymology|the etymology of lion]]'}|lua}}.
 
=== Find namespace id ===
 
<source lang="lua">
mHatnote._findNamespaceIdfindNamespaceId(link, removeColon)
</source>
 
Line 89:
 
;Examples:
: {{code|mHatnote._findNamespaceIdfindNamespaceId('Lion')|lua}} &rarr; 0
: {{code|mHatnote._findNamespaceIdfindNamespaceId('Category:Lions')|lua}} &rarr; 14
: {{code|mHatnote._findNamespaceIdfindNamespaceId(':Category:Lions')|lua}} &rarr; 14
: {{code|mHatnote._findNamespaceIdfindNamespaceId(':Category:Lions', false)|lua}} &rarr; 0 (the namespace is detected as ":Category", rather than "Category")
 
=== Make wikitext error ===
 
<source lang="lua">
mHatnote._makeWikitextErrormakeWikitextError(msg, demo)
</source>
 
Line 103:
 
Example:
:{{code|mHatnote._makeWikitextErrormakeWikitextError('an error has occurred')|lua}} &rarr; <strong class="error">Error: an error has occurred.</strong>
 
== Examples ==