Module:Infobox

From MycoTaxa
Revision as of 16:54, 2 May 2025 by Alan Rockefeller (talk | contribs) (Created page with "local p = {} -- Function to generate an infobox function p.createInfobox(frame) local args = frame.args local infobox = '<table class="infobox" style="width: 22em; text-align: left; border: 1px solid #aaa; border-radius: 5px;">' for k, v in pairs(args) do if k ~= 'image' then infobox = infobox .. '<tr><th>' .. k .. '</th><td>' .. v .. '</td></tr>' end end if args['image'] then infobox = infobox .. '<tr><th>Im...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Module:Infobox is a module that implements the {{Infobox}} template. Please see the template page for usage instructions.

Tracking categories


local p = {}

-- Function to generate an infobox
function p.createInfobox(frame)
    local args = frame.args
    local infobox = '<table class="infobox" style="width: 22em; text-align: left; border: 1px solid #aaa; border-radius: 5px;">'

    for k, v in pairs(args) do
        if k ~= 'image' then
            infobox = infobox .. '<tr><th>' .. k .. '</th><td>' .. v .. '</td></tr>'
        end
    end
    
    if args['image'] then
        infobox = infobox .. '<tr><th>Image</th><td><img src="' .. args['image'] .. '" alt="Image" style="width: 100%; max-height: 200px; object-fit: contain;"></td></tr>'
    end
    
    infobox = infobox .. '</table>'
    return infobox
end

return p