Jump to content

Module:CapiuntoTest: Difference between revisions

From The Commentary Community Wiki
No edit summary
No edit summary
Tag: Reverted
Line 4: Line 4:


function p.main(frame)
function p.main(frame)
local args = frame:getParent().args
    local args = frame:getParent().args
local headerStyle
 
if args.headerstyle and args.headerstyle ~= '' then
    local headerStyle
headerStyle = string.format('background-color:%s;', args.headerstyle)
    if args.headerstyle and args.headerstyle ~= '' then
else
        headerStyle = string.format('background-color:%s;', args.headerstyle)
headerStyle = 'background-color:grey;'
    else
end
        headerStyle = 'background-color:grey;'
local retval = capiunto.create( {
    end
title = args.title,
 
headerStyle = headerStyle,  
    local retval = capiunto.create({
} )
        title = args.title,
:addImage( args.image, args.caption )
        headerStyle = headerStyle,
:addRow( 'Also Known As', args.foo )
    })
:addHeader( 'Social Media Links' )
 
:addRow( 'Links', args.bar )
    -- NEW: Support slideshow gallery (multiple images with arrows)
     :addHeader( 'Status' )
    if args.gallery and args.gallery ~= '' then
    :addRow( 'Current Status', args.sta )
        retval:addWikitext(args.gallery)
return retval
    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
end


return p
return p

Revision as of 06:20, 13 March 2026

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