Module:Author initials

From Wikisource
Jump to navigation Jump to search
require('strict')
local getArgs = require('Module:Arguments').getArgs
local p = {}

function p.main(frame)
	local args = getArgs(frame)
	return p._main(args)
end

function p._main(args)
	local str = ""

	local initials = args['initials'] or ""
	mw.ustring.gsub(initials, '[^A-Z]', '')
	local data = args['data']

	local authors = mw.loadData('Module:Author initials/' .. data)
	local author = authors[initials] or ""

	if author and initials then
		str = '[[' .. author .. '|' .. initials .. ']]'
	else
		str = '[[' .. 'Category:' .. 'Pages calling author intitials with errors' .. ']]'
	end
	return str
end

return p