Module:government: Difference between revisions

From Laenkea
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 4: Line 4:


-- COLOUR DATA
-- COLOUR DATA
local data = {
local data = mw.loadData("Module:government/data")
-- base cases
["nominative"] = {["label"] = "nominative", ["colour"] = "ffb3ba"},
["accusative"] = {["label"] = "accusative", ["colour"] = "ffdfba"},
["dative"] = {["label"] = "dative", ["colour"] = "ffffba"},
["genitive"] = {["label"] = "genitive", ["colour"] = "baffc9"},
["locative"] = {["label"] = "locative", ["colour"] = "bae1ff"},
["instrumental"] = {["label"] = "instrumental", ["colour"] = "f1b3ff"},
}
 
-- LAEFEVIAN CASES
data["inessive"] = {["label"] = "inessive", ["colour"] = data["locative"].colour}
data["illative"] = {["label"] = "illative", ["colour"] = data["accusative"].colour}
 
-- ALIASES
data["nom"] = data["nominative"]
data["acc"] = data["accusative"]
data["dat"] = data["dative"]
data["gen"] = data["genitive"]
data["loc"] = data["locative"]
data["ins"] = data["instrumental"]
data["inst"] = data["instrumental"]
data["ill"] = data["illative"]
data["ine"] = data["inessive"]


function export.generate(frame)
function export.generate(frame)

Revision as of 22:35, 26 October 2023

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"}})
]]