Module:EPAR

MyWikiBiz, Author Your Legacy — Thursday December 12, 2024
Jump to navigationJump to search

Documentation for this module may be created at Module:EPAR/doc

--[[
European public assessment reports
--]]

local p = {}

local epardata = mw.loadData("Module:EPAR/data")

function p.pname2url(frame)
	local name = mw.text.trim(frame.args[1] or ""):lower()
	if name == "" then
		return nil
	else
		return epardata.Purl[name]
	end
end

function p.nname2url(frame)
	local name = mw.text.trim(frame.args[1] or ""):lower()
	local sep = (frame.args.sep or ""):gsub('"', '')
	if sep == "" then sep = ", " end
	if name == "" or not epardata.Nurl[name] then
		return nil
	else
		-- epardata.Nurl[name] is table of Pnames
		local out = {}
		for idx, pn in ipairs(epardata.Nurl[name]) do
			if epardata.Purl[pn] then
				out[#out + 1] = "[" .. epardata.Purl[pn] .. " " .. pn .. "]"
			end
		end
		return table.concat(out, sep)
	end
end

return p