Editing Module:TableGeneratorGive feedback
Jump to navigation
Jump to search
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
| Latest revision | Your text | ||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function p.generateTable(frame) | |||
local args = frame:getParent().args | |||
local output = {} | |||
local row = {} | |||
for i = 1, #args / 2 do | |||
local statName = args['stat_name' .. i] | |||
local statValue = args['stat_value' .. i] | |||
if statName and statValue then | |||
table.insert(row, '<td>' .. statName .. ' ' .. statValue .. '</td>') | |||
-- Every 3rd entry creates a new row | |||
if #row == 3 then | |||
table.insert(output, '<tr>' .. table.concat(row) .. '</tr>') | |||
row = {} -- Clear row for next set of values | |||
end | end | ||
end | end | ||
end | end | ||
if not | -- Handle remaining cells (if not divisible by 3) | ||
if #row > 0 then | |||
while #row < 3 do | |||
table.insert(row, '<td></td>') -- Fill remaining cells with empty | |||
end | |||
table.insert(output, '<tr>' .. table.concat(row) .. '</tr>') | |||
end | end | ||
return | return table.concat(output) | ||
end | end | ||
return p | return p | ||