Module:EnumValues

From Resonite Wiki
Revision as of 22:37, 27 February 2024 by PJB (talk | contribs) (Try to add anchor links for enum names)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This module is used by the implementation of Template:Table EnumValues


-- test in console:
-- =p.main(mw.getCurrentFrame():newChild{title="Template:Table EnumValues",args={"Left", "1", "Left"}}:newChild{title="Module:Test",args={}})

local p = {}

function p.main(frame)
	local body = ""
	
	local templateFrame = frame:getParent()
	local i = 0

	while true do
		local argI = i * 3 + 1
		local name = templateFrame.args[argI]
		local value = templateFrame.args[argI + 1]
		local description = templateFrame.args[argI + 2]

		if name == nil then
			break
		end

		description = mw.text.trim(description)

		body = body.."|-\n"
		body = body.."|<code id=\""..name.."\">"..name.."</code>\n"
		body = body.."|"..value.."\n"
		body = body.."|"..description.."\n"
		i = i + 1
	end
	
	return body
end

return p