Modul:Data/DE-096775621

aus Wikipedia, der freien Enzyklopädie
local p = {}
local tSel = {
	["Einwohnerzahlen"] = 1,
}

function p.getData(tArgs)
	if type(tArgs) == type({}) then
		if not tonumber(tArgs.selection) then
			tArgs.selectionName = tArgs.selection
		end
		tArgs.selection = tSel[tArgs.selectionName] or tonumber(tArgs.selection)
		if tArgs.selection then
			local b, tSub = pcall(require, "Module:Data/DE-096775621/" .. tArgs.selection)
			if type(tSub) == type({}) then
				if tSub.getData then
					return tSub.getData(tArgs)
				else
					tArgs.selectionError = tArgs.selectionError or "[[Module:Data/DE-096775621/" .. tArgs.selection .."]].getData"
					return tArgs.selectionError
				end
			else
				tArgs.selectionError = tArgs.selectionError or "[[Module:Data/DE-096775621/" .. tArgs.selection .."]]"
				return tArgs.selectionError
			end
		else
			local s = '{| class="wikitable"\n!selectionName\n!selection\n'
			for i, v in pairs(tSel) do
				s = s .. "|-\n|" .. i .. "\n|" .. v .. "\n"
			end
			return s .. "|}"
		end
	else
		return '<span class="error">tArgs = {}</span>'
	end
end

function p.invokeData(frame)
	local t = {}
	t.selection = frame.args[1] or frame.args["selection"]
	t.version = frame.args[2] or frame.args["version"]
	t.key = frame.args[3] or frame.args["key"]
	t.field = frame.args[4] or frame.args["field"]
	for i, v in pairs(frame.args) do
		t[i] = t[i] or v
	end
	return p.getData(t)
end

return p