Module:EnumValues: Difference between revisions

From Resonite Wiki
I didn't test this code at all, just copy pasted it, it's fine right 🙂
 
Trim newline from description
Line 19: Line 19:
break
break
end
end
description = mw.text.trim(description)


body = body.."|-\n"
body = body.."|-\n"

Revision as of 21:31, 27 February 2024

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

return p