Jump to content

Module:Main list

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Codename Lisa (talk | contribs) at 21:57, 6 February 2016 (Implemented second parameter). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

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

local mHatnote = require('Module:Hatnote')
local mArguments -- lazily initialise

local p = {}

function p.mainList(frame)
	mArguments = require('Module:Arguments')
	local args = mArguments.getArgs(frame, {parentOnly = true})
	local page1 = args[1]
	if not page1 then
		return mHatnote.makeWikitextError(
			'no page name specified',
			'Template:Main list#Errors',
			args.category
		)
	end
    local page2 = args[2]
	return p._mainList(page1, page2)
end

function p._mainList(page1, page2)
	page1 = mHatnote._formatLink(page1)
    if page2 then
        local text = string.format('For a more comprehensive list, see %s and %s.', page1, page2)
    else
    	local text = string.format('For a more comprehensive list, see %s.', page1)
	end
	return mHatnote._hatnote(text)
end

return p