Module:infobox: Difference between revisions

Jump to navigation Jump to search
ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
No edit summary
No edit summary
Line 9: Line 9:
if data.sections then
if data.sections then
for _, section in ipairs(data.sections) do
for _, section in ipairs(data.sections) do
if section.items then
local num_items = #section
local num_items = #section.items
for i, item in ipairs(section) do
for i, item in ipairs(section.items) do
local row_class = ""
local row_class = ""
if i == 1 then
if i == 1 then
row_class = ' class="infobox-section-toprow"'
row_class = ' class="infobox-section-toprow"'
elseif i == num_items then
elseif i == num_items then
row_class = ' class="infobox-section-bottomrow"'
row_class = ' class="infobox-section-bottomrow"'
end
if (not item.label) or (not item.value) then
error("each item must have a label and value")
end
ret = ret .. '\n|-' .. row_class
ret = ret .. '\n! ' .. item.label .. ' | ' .. item.value
end
end
if (not item.label) or (not item.value) then
error("each item must have a label and value")
end
ret = ret .. '\n|-' .. row_class
ret = ret .. '\n! ' .. item.label .. ' | ' .. item.value
end
end
end
end
Line 46: Line 44:
i = i + 2
i = i + 2
end
end
if #section > 0 then table.insert(data.sections, section) else error("BLABLABLA") end
if #section > 0 then table.insert(data.sections, section) end
i = i + 1
i = i + 1
end
end
mw.logObject(data)
return export.make_infobox(data)
return export.make_infobox(data)
end
end


return export
return export

Navigation menu