« Module:Hatnote/doc » : différence entre les versions

De Adadov.net wiki
Aucun résumé des modifications
mAucun résumé des modifications
 
(2 versions intermédiaires par le même utilisateur non affichées)
Ligne 1 : Ligne 1 :
This is a meta-module that provides various functions for making hatnotes. It implements the {{tl|hatnote}} template, for use in hatnotes at the top of pages, and the {{tl|format link}} template, which is used to format a wikilink for use in hatnotes. It also contains a number of helper functions for use in other Lua hatnote modules.
<!--This is a meta-module that provides various functions for making hatnotes. It implements the {{tl|hatnote}} template, for use in hatnotes at the top of pages, and the {{tl|format link}} template, which is used to format a wikilink for use in hatnotes. It also contains a number of helper functions for use in other Lua hatnote modules.


== Use from wikitext ==
== Use from wikitext ==
Ligne 56 : Ligne 56 :


;Examples:
;Examples:
: {{code|mHatnote._formatLink('Lion')|lua}} &rarr; <nowiki>[[Lion]]</nowiki> &rarr; {{format link|Lion}}
: {{code|mHatnote._formatLink('SysAdmin')|lua}} &rarr; <nowiki>[[SysAdmin]]</nowiki> &rarr; {{format link|SysAdmin}}
: {{code|mHatnote._formatLink('Lion#Etymology')|lua}} &rarr; <nowiki>[[Lion#Etymology|Lion § Etymology]]</nowiki> &rarr; {{format link|Lion#Etymology}}
: {{code|mHatnote._formatLink('SysAdmin#Etymology')|lua}} &rarr; <nowiki>[[SysAdmin#Etymology|SysAdmin § Etymology]]</nowiki> &rarr; {{format link|SysAdmin#Etymology}}
: {{code|mHatnote._formatLink('Category:Lions')|lua}} &rarr; <nowiki>[[:Category:Lions]]</nowiki> &rarr; {{format link|Category:Lions}}
: {{code|mHatnote._formatLink('Category:SysAdmin')|lua}} &rarr; <nowiki>[[:Category:SysAdmin]]</nowiki> &rarr; {{format link|Category:SysAdmin}}
: {{code|mHatnote._formatLink('Lion#Etymology', 'Etymology of lion')|lua}} &rarr; <nowiki>[[Lion#Etymology|Etymology of lion]]</nowiki> &rarr; {{format link|Lion#Etymology|Etymology of lion}}
: {{code|mHatnote._formatLink('SysAdmin#Etymology', 'Etymology of SysAdmin')|lua}} &rarr; <nowiki>[[SysAdmin#Etymology|Etymology of SysAdmin]]</nowiki> &rarr; {{format link|SysAdmin#Etymology|Etymology of SysAdmin}}


=== Format pages ===
=== Format pages ===
Ligne 67 : Ligne 67 :
</syntaxhighlight>
</syntaxhighlight>


Formats a list of pages using the [[#Format link|_formatLink]] function, and returns the result as an array. For example, the code {{code|mHatnote.formatPages('Lion', 'Category:Lions', 'Lion#Etymology')|lua}} would produce an array like {{code|{'[[Lion]]', '[[:Category:Lions]]', '[[Lion#Etymology|Lion § Etymology]]'}|lua}}.
Formats a list of pages using the [[#Format link|_formatLink]] function, and returns the result as an array. For example, the code {{code|mHatnote.formatPages('SysAdmin', 'Category:SysAdmin', 'SysAdmin#Etymology')|lua}} would produce an array like {{code|{'[[SysAdmin]]', '[[:Category:SysAdmin]]', '[[SysAdmin#Etymology|SysAdmin § Etymology]]'}|lua}}.


=== Format page tables ===
=== Format page tables ===
Ligne 75 : Ligne 75 :
</syntaxhighlight>
</syntaxhighlight>


Takes a list of page/display tables, formats them with the [[#Format link|_formatLink]] 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.formatPages({'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}}.
Takes a list of page/display tables, formats them with the [[#Format link|_formatLink]] 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.formatPages({'SysAdmin', 'the SysAdmin article'}, {'Category:SysAdmin'}, {'SysAdmin#Etymology', 'the etymology of SysAdmin'})|lua}} would produce an array like {{code|{'[[SysAdmin|the SysAdmin article]]', '[[:Category:SysAdmin]]', '[[SysAdmin#Etymology|the etymology of SysAdmin]]'}|lua}}.


=== Find namespace id ===
=== Find namespace id ===
Ligne 86 : Ligne 86 :


;Examples:
;Examples:
: {{code|mHatnote.findNamespaceId('Lion')|lua}} &rarr; 0
: {{code|mHatnote.findNamespaceId('SysAdmin')|lua}} &rarr; 0
: {{code|mHatnote.findNamespaceId('Category:Lions')|lua}} &rarr; 14
: {{code|mHatnote.findNamespaceId('Category:SysAdmin')|lua}} &rarr; 14
: {{code|mHatnote.findNamespaceId(':Category:Lions')|lua}} &rarr; 14
: {{code|mHatnote.findNamespaceId(':Category:SysAdmin')|lua}} &rarr; 14
: {{code|mHatnote.findNamespaceId(':Category:Lions', false)|lua}} &rarr; 0 (the namespace is detected as ":Category", rather than "Category")
: {{code|mHatnote.findNamespaceId(':Category:SysAdmin', false)|lua}} &rarr; 0 (the namespace is detected as ":Category", rather than "Category")


=== Make wikitext error ===
=== Make wikitext error ===
Ligne 112 : Ligne 112 :
* [[Module:Main]]
* [[Module:Main]]


-->
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
<!-- Categories go here and interwikis go in Wikidata. -->
<!-- Categories go here and interwikis go in Wikidata. -->


}}</includeonly>
}}</includeonly>

Dernière version du 8 février 2023 à 08:00