Jump to content
Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

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

local p = {}
local getArgs = require('Module:Arguments').getArgs

function p.main(frame)

	local args = getArgs(frame, {
		removeBlanks = false,
		trim = false
	})

	local output = '{|'

	-- Table attributes
	if args.class then
		output = output .. ' class="' .. mw.text.trim(args.class) .. '"'
	end

	if args.style then
		output = output .. ' style="' .. mw.text.trim(args.style) .. '"'
	end

	output = output .. '\n'

	-- Headers
	if args.headers then
		for _, header in ipairs(mw.text.split(args.headers, '\n\n', true)) do
			header = mw.text.trim(header)

			if header ~= '' then
				header = header:gsub('%|%|', '!!')

				if args.headerclass then
					output = output .. '|- class="' .. mw.text.trim(args.headerclass) .. '"\n'
				else
					output = output .. '|-\n'
				end

				output = output .. '!' .. header .. '\n'
			end
		end
	end

	-- Rows
	if args.rows then
		for _, row in ipairs(mw.text.split(args.rows, '\n\n', true)) do
			row = mw.text.trim(row)

			if row ~= '' then
				output = output .. '|-\n|' .. row .. '\n'
			end
		end
	end

	output = output .. '|}'

	return output
end

return p