Pojdi na vsebino

Modul:Main list

Iz Wikipedije, proste enciklopedije
Documentation icon Dokumentacija modula[predogled] [uredi] [zgodovina] [osveži]

This module produces a "For a more comprehensive list, see [...]" link. It implements the {{main list}} template.

Use from wikitext

[uredi kodo]

This module cannot be used directly from #invoke. Instead, it can only be used through the {{main list}} template. Please see the template page for documentation.

Use from other Lua modules

[uredi kodo]

Load the module:

local mMainList = require('Module:Main list')

You can then use the _mainList function like this:

mMainList._mainList (page1, page2)

The page1 variable is the page to be linked to, and is required. The page name can include a section link if desired. If the page includes a section link, it is automatically formatted as page § section, rather than the MediaWiki default of page#section.

The page2 variable is optional; it is a second page link.

Example 1

[uredi kodo]
mMainList._mainList ('Wikipedia:Hatnote#Hatnote templates')

Produces:

<div class="hatnote">For a more comprehensive list, see [[Wikipedia:Hatnote#Hatnote templates|Wikipedia:Hatnote § Hatnote templates]].</div>

Displays as:

For a more comprehensive list, see Wikipedia:Hatnote § Hatnote templates.

Example 2

[uredi kodo]
mMainList._mainList ('Wikipedia:Hatnote#Hatnote templates','Wikipedia:Template messages/Cleanup#Cleanup')

Produces:

<div class="hatnote">For a more comprehensive list, see [[Wikipedia:Hatnote#Hatnote templates|Wikipedia:Hatnote § Hatnote templates]] and [[Wikipedia:Template messages/Cleanup#Cleanup|Wikipedia:Template messages/Cleanup § Cleanup]].</div>

Displays as:

Technical details

[uredi kodo]

This module uses Module:Hatnote to format the hatnote text and Module:Arguments to fetch the arguments from wikitext.

--[[
-- This module produces a "For more details on this topic" link. It implements
-- the {{Main list}} template.
--]]

local mHatnote = require('Modul:Hatnote')
local mHatlist = require('Modul:Hatnote list')
local mArguments -- lazily initialise
local mTableTools -- lazily initialise
local p = {}

function p.mainList(frame)
	mArguments = require('Modul:Arguments')
	mTableTools = require('Modul:TableTools')
	local args = mArguments.getArgs(frame, {parentOnly = true})
	if not args[1] then
		return mHatnote.makeWikitextError(
			'ime strani ni navedeno',
			'Predloga:Main list#Errors',
			args.category
		)
	end
	return p._mainList(mTableTools.compressSparseArray(args))
end

function p._mainList(args)
	local pages = mHatlist.andList(args, true)
	local text = string.format('Za bolj izčrpen seznam glej %s.', pages)
	return mHatnote._hatnote(text)
end

return p