Module:government

From Laenkea
Revision as of 22:35, 26 October 2023 by TheNightAvl (talk | contribs)
Jump to navigation Jump to search

See {{with}}. To add to the recognised argument list, edit Module:government/data.


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


-- COLOUR DATA
local data = mw.loadData("Module:government/data")

function export.generate(frame)
	local args = getArgs(frame)
	local label = ""
	local colour = ""
	
	if not args[1] then
		error("First argument required")	
	end
	
	if data[args[1]] then
		label = data[args[1]].label
		colour = args[2] or data[args[1]].colour
	else
		label = args[1]
		colour = args[2] or nil
	end
	
	if colour then
		return "[<span style=\"background-color: #" .. colour .. ";\">+" .. label .. "</span>]"
	else
		return "[+" .. label .. "]"
	end
end

return export

--[[
Debug console test string:
=p.generate(mw.getCurrentFrame():newChild{title="whatever",args={"accusative"}})
]]