Neidio i'r cynnwys

Modiwl:Table style

Oddi ar Wicidestun

Documentation for this module may be created at Modiwl:Table style/doc

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

local raw_styles = mw.loadData('Module:Table style/data')
local styles = {}
for k, v in pairs(raw_styles) do
	local style = v.style
	local names = v.aliases
	styles[k] = style
	for _, name in pairs(names) do
		styles[name] = style
	end
end

function p.main(frame)
	local args = getArgs(frame)
	return p._main(args)
end

function p._main(args)
	local str = 'style="'
	for _, arg in pairs(args) do
		if styles[arg] ~= nil and styles[arg] ~= '' then
	    	str = str .. styles[arg]
	    else
	    	str = str .. arg .. ";"
	    end
	end
	str = str .. '"'
	return str
end

return p