Module:Infobox: Difference between revisions
Appearance
Created the infobox module  |
Added support for categories |
||
| Line 12: | Line 12: | ||
local rows = tonumber(args.rows) or 10 | local rows = tonumber(args.rows) or 10 | ||
local categories = tonumber(args.categories) or 5 | |||
for i = 1, rows do | for i = 1, rows do | ||
| Line 19: | Line 20: | ||
table.insert(out, '|-\n| ' .. label .. ' || ' .. data) | table.insert(out, '|-\n| ' .. label .. ' || ' .. data) | ||
end | end | ||
end | |||
for i = 1, categories do | |||
local category = args['category' .. i] | |||
table.insert(out, '|-\n! colspan="2" style="background: #F4BB44;" | ' .. args['category' .. i]) | |||
end | end | ||
Revision as of 15:57, 21 June 2025
Documentation for this module may be created at Module:Infobox/doc
local p = {}
function p.infobox(frame)
local args = frame:getParent().args
local out = {}
table.insert(out, '{| class="infobox" style="width: 250px;"')
if args.title then
table.insert(out, '|-\n! colspan="2" style="font-size:120%; background:#ccc;" | ' .. args.title)
end
local rows = tonumber(args.rows) or 10
local categories = tonumber(args.categories) or 5
for i = 1, rows do
local label = args['label' .. i]
local data = args['data' .. i]
if label and data then
table.insert(out, '|-\n| ' .. label .. ' || ' .. data)
end
end
for i = 1, categories do
local category = args['category' .. i]
table.insert(out, '|-\n! colspan="2" style="background: #F4BB44;" | ' .. args['category' .. i])
end
table.insert(out, '|}')
return table.concat(out, '\n')
end
return p