Unterseiten


local p = {}

function p.TableHeader(frame)
	return p.tableHeader(frame.args)
end

function p.tableHeader(args)
--	mw.log("tableHeader(args)")
--	mw.logObject(args, "args")
	args = args or {}
	local t = "<table class=" ..
		(args.class or "\"wikitable sortable\"") .. " border=\"1\">\n"
	if #args > 0 then
		t = t .. "<tr>\n"
		for _, a in ipairs(args) do
			th_args = ""
			if type(a) == "table" then
				if a.th_args ~= nil then
					th_args = " " .. a.th_args
				end
				a = a[1]
			end
			t = t .. "  <th" .. th_args .. ">" .. a .. "</th>\n"
		end
		t = t .. "</tr>\n"
	end
--	mw.logObject(t, "t")
	return t
end

function p.TableLine(frame)
	return p.tableLine(frame.args)
end

function p.tableLine(args)
--	mw.log("tableLine(args)")
--	mw.logObject(args, "args")
	local tr_args = ""
	local td_args = ""
	if args.tr_args ~= nil then
		tr_args = " " .. args.tr_args
	end
	local t = "<tr " .. tr_args .. ">\n"
	for _, a in ipairs(args) do
		td_args = ""
		if type(a) == "table" then
			if a.td_args ~= nil then
				td_args = " " .. a.td_args
			end
			a = a[1]
		end
		t = t .. "  <td" .. td_args .. ">" .. a .. "</td>\n"
	end
	t = t .. "</tr>\n"
--	mw.logObject(t, "t")
	return t
end

function p.TableFooter(frame)
	return p.tableFooter()
end

function p.tableFooter()
--	mw.log("tableFooter()")
	return "</table>"
end

return p