Jump to content

Module:CapiuntoTest

From The Commentary Community Wiki
Revision as of 06:20, 13 March 2026 by 2pacalypse (talk | contribs)

Documentation for this module may be created at Module:CapiuntoTest/doc

local capiunto = require 'capiunto'

local p = {}

function p.main(frame)
    local args = frame:getParent().args

    local headerStyle
    if args.headerstyle and args.headerstyle ~= '' then
        headerStyle = string.format('background-color:%s;', args.headerstyle)
    else
        headerStyle = 'background-color:grey;'
    end

    local retval = capiunto.create({
        title = args.title,
        headerStyle = headerStyle,
    })

    -- NEW: Support slideshow gallery (multiple images with arrows)
    if args.gallery and args.gallery ~= '' then
        retval:addWikitext(args.gallery)
    else
        -- Fallback to single image (backward compatible)
        retval:addImage(args.image, args.caption)
    end

    -- Your existing rows (hardcoded in the official example; adapt if your version loops dynamically)
    retval:addRow('Foo', args.foo)
        :addHeader('A header between the data rows')
        :addRow('Bar', args.bar)

    -- Add your extra fields (e.g. sta) here if your module handles them dynamically
    if args.sta and args.sta ~= '' then
        retval:addRow('Status', args.sta)  -- or whatever label you want
    end

    return retval
end

return p