I didn't test this code at all, just copy pasted it, it's fine right 🙂  |
Try to add anchor links for enum names  |
||
(One intermediate revision by the same user not shown) | |||
Line 19: | Line 19: | ||
break | break | ||
end | end | ||
description = mw.text.trim(description) | |||
body = body.."|-\n" | body = body.."|-\n" | ||
body = body.."|<code>"..name.."</code>\n" | body = body.."|<code id=\""..name.."\">"..name.."</code>\n" | ||
body = body.."|"..value.."\n" | body = body.."|"..value.."\n" | ||
body = body.."|"..description.."\n" | body = body.."|"..description.."\n" |
Latest revision as of 22:37, 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 id=\""..name.."\">"..name.."</code>\n"
body = body.."|"..value.."\n"
body = body.."|"..description.."\n"
i = i + 1
end
return body
end
return p