Difference between revisions of "Hatnote/doc"

From blackwiki
Jump to navigation Jump to search
test>Mr. Stradivarius
(add hatnote function)
test>Mr. Stradivarius
(add rellink and examples)
Line 22: Line 22:
  
 
Formats the string <var>s</var> as a hatnote. This encloses <var>s</var> in the tags {{tag|div|params=class="dablink"}}. The CSS of the dablink class is defined in [[MediaWiki:Common.css]].
 
Formats the string <var>s</var> as a hatnote. This encloses <var>s</var> in the tags {{tag|div|params=class="dablink"}}. The CSS of the dablink class is defined in [[MediaWiki:Common.css]].
 +
 +
; Example
 +
 +
<source lang="lua">
 +
mHatnote._hatnote('This is a hatnote.')
 +
</source>
 +
 +
Produces:
 +
{{tag|div|content=This is a hatnote.|params=class="dablink"}}
 +
 +
Displays as:
 +
{{hatnote|This is a hatnote.}}
 +
 +
=== Rellink ===
 +
 +
<source lang="lua">
 +
mHatnote._rellink(s, extraclasses)
 +
</source>
 +
 +
Formats the string <var>s</var> as a "related articles" link. This encloses <var>s</var> in the tags {{tag|div|params=class="rellink"}}. The CSS of the dablink class is defined in [[MediaWiki:Common.css]]. Extra classes can be added as the string <var>extraclasses</var>.
 +
 +
; Example 1
 +
 +
<source lang="lua">
 +
mHatnote._rellink('This is a related article link.')
 +
</source>
 +
 +
Produces:
 +
{{tag|div|content=This is a related article link.|params=class="rellink"}}
 +
 +
Displays as:
 +
{{rellink|This is a related article link.}}
 +
 +
; Example 1
 +
 +
<source lang="lua">
 +
mHatnote._rellink('This is a related article link.')
 +
</source>
 +
 +
Produces:
 +
{{tag|div|content=This is a related article link.|params=class="rellink"}}
 +
 +
Displays as:
 +
{{rellink|This is a related article link.}}
 +
 +
; Example 2
 +
 +
<source lang="lua">
 +
mHatnote._rellink('This is a related article link.', 'boilerplate seealso')
 +
</source>
 +
 +
Produces:
 +
{{tag|div|content=This is a related article link.|params=class="rellink boilerplate seealso"}}
 +
 +
Displayed as:
 +
{{rellink|This is a related article link.|extraclasses=boilerplate seealso}}
  
 
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
 
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||

Revision as of 11:57, 24 April 2014

This is a meta-module that provides various functions for making hatnotes. It implements the {{hatnote}} template, for use in disambiguation hatnotes at the top of pages, and the {{rellink}} template, for use in making links to related articles directly under section headings. It also implements the {{format hatnote link}} template, which is used to format a wikilink for use in hatnotes.

Use from wikitext

The functions in this module cannot be used directly from #invoke, and must be used through templates instead. Please see Template:Hatnote, Template:Rellink and Template:Format hatnote link for documentation.

Use from other Lua modules

To load this module from another Lua module, use the following code.

local mHatnote = require('Module:Hatnote')

You can then use the functions as documented below.

Hatnote

mHatnote._hatnote(s)

Formats the string s as a hatnote. This encloses s in the tags <div class="dablink">...</div>. The CSS of the dablink class is defined in MediaWiki:Common.css.

Example
mHatnote._hatnote('This is a hatnote.')

Produces: <div class="dablink">This is a hatnote.</div>

Displays as:

Rellink

mHatnote._rellink(s, extraclasses)

Formats the string s as a "related articles" link. This encloses s in the tags <div class="rellink">...</div>. The CSS of the dablink class is defined in MediaWiki:Common.css. Extra classes can be added as the string extraclasses.

Example 1
mHatnote._rellink('This is a related article link.')

Produces: <div class="rellink">This is a related article link.</div>

Displays as: Template:Rellink

Example 1
mHatnote._rellink('This is a related article link.')

Produces: <div class="rellink">This is a related article link.</div>

Displays as: Template:Rellink

Example 2
mHatnote._rellink('This is a related article link.', 'boilerplate seealso')

Produces: <div class="rellink boilerplate seealso">This is a related article link.</div>

Displayed as: Template:Rellink