Difference between revisions of "Module:InfoboxAlt"
Jump to navigation
Jump to search
m |
|||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
| − | function p.main() | + | function p.main(frame) |
| − | return " | + | local args = frame:getParent().args |
| + | local title = args.title or args.name or "" | ||
| + | |||
| + | local rows = {} | ||
| + | |||
| + | for k, v in pairs(args) do | ||
| + | if k ~= "title" and k ~= "name" and v ~= "" then | ||
| + | table.insert(rows, | ||
| + | string.format( | ||
| + | '<tr><th class="infobox-label">%s</th><td class="infobox-data">%s</td></tr>', | ||
| + | k, | ||
| + | v | ||
| + | ) | ||
| + | ) | ||
| + | end | ||
| + | end | ||
| + | |||
| + | table.sort(rows) | ||
| + | |||
| + | return string.format([[ | ||
| + | <table class="infobox"> | ||
| + | <caption class="infobox-title">%s</caption> | ||
| + | %s | ||
| + | </table> | ||
| + | ]], title, table.concat(rows, "\n")) | ||
end | end | ||
return p | return p | ||
Latest revision as of 11:21, 4 January 2026
Documentation for this module may be created at Module:InfoboxAlt/doc
local p = {}
function p.main(frame)
local args = frame:getParent().args
local title = args.title or args.name or ""
local rows = {}
for k, v in pairs(args) do
if k ~= "title" and k ~= "name" and v ~= "" then
table.insert(rows,
string.format(
'<tr><th class="infobox-label">%s</th><td class="infobox-data">%s</td></tr>',
k,
v
)
)
end
end
table.sort(rows)
return string.format([[
<table class="infobox">
<caption class="infobox-title">%s</caption>
%s
</table>
]], title, table.concat(rows, "\n"))
end
return p