Module:Wp/nod/Further

Documentation for this module may be created at Module:Wp/nod/Further/doc

--[[
-- This module produces a "Further information" link. It implements
-- the {{further}} template.
--]]

local mHatnote = require('Module:Wp/nod/Hatnote')
local mHatlist = require('Module:Wp/nod/Hatnote list')
local mArguments -- lazily initialise
local mTableTools -- lazily initialise
local p = {}

function p.further (frame)
	mArguments = require('Module:Wp/nod/Arguments')
	mLabels = require('Module:Wp/nod/Labelled list hatnote')
	local args = mArguments.getArgs(frame, {parentOnly = true})
	local topic, category = args.topic, args.category
	local options = {selfref = args.selfref}
	pages = mLabels.preprocessDisplays(args)
	if #pages == 0 then
		return mHatnote.makeWikitextError(
			'no page names specified',
			'Template:Further#Errors',
			category
		)
	end
	return p._further(pages, topic, options)
end

function p._further (pages, topic, options)
	topic = topic and (' on '..topic) or ''
	local text = string.format('Further information%s: %s', topic, mHatlist.andList(pages, true))
	return mHatnote._hatnote(text, options)
end

return p