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:Wikitable2/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
    for k, v in pairs(args) do
    	if k ~= 'header1' and not k:match('^header%d+$') and not k:match('^row%d+$') then
    		output = output .. ' ' .. k .. '="' .. v .. '"'
    	end
    end

	output = output .. '\n'

    -- Headers
    for i = 1, 50 do
    	if args['header' .. i] then
    		local header = args['header' .. i]
    		header = header:gsub('%|%|', '!!')

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

    -- Rows
    for i = 1, 50 do
    	if args['row' .. i] then
		output = output .. '|-\n|' .. args['row' .. i] .. '\n'
    	end
    end

    	output = output .. '|}'

    	return output
    end

return p