« Module:Hatnote/doc » : différence entre les versions
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(' | : {{code|mHatnote._formatLink('SysAdmin')|lua}} → <nowiki>[[SysAdmin]]</nowiki> → {{format link|SysAdmin}} | ||
: {{code|mHatnote._formatLink(' | : {{code|mHatnote._formatLink('SysAdmin#Etymology')|lua}} → <nowiki>[[SysAdmin#Etymology|SysAdmin § Etymology]]</nowiki> → {{format link|SysAdmin#Etymology}} | ||
: {{code|mHatnote._formatLink('Category: | : {{code|mHatnote._formatLink('Category:SysAdmin')|lua}} → <nowiki>[[:Category:SysAdmin]]</nowiki> → {{format link|Category:SysAdmin}} | ||
: {{code|mHatnote._formatLink(' | : {{code|mHatnote._formatLink('SysAdmin#Etymology', 'Etymology of SysAdmin')|lua}} → <nowiki>[[SysAdmin#Etymology|Etymology of SysAdmin]]</nowiki> → {{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(' | 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({' | 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(' | : {{code|mHatnote.findNamespaceId('SysAdmin')|lua}} → 0 | ||
: {{code|mHatnote.findNamespaceId('Category: | : {{code|mHatnote.findNamespaceId('Category:SysAdmin')|lua}} → 14 | ||
: {{code|mHatnote.findNamespaceId(':Category: | : {{code|mHatnote.findNamespaceId(':Category:SysAdmin')|lua}} → 14 | ||
: {{code|mHatnote.findNamespaceId(':Category: | : {{code|mHatnote.findNamespaceId(':Category:SysAdmin', false)|lua}} → 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