Jump to content

Module:CapiuntoTest: Difference between revisions

From The Commentary Community Wiki
No edit summary
Tag: Reverted
m Reverted edit by 2pacalypse (talk) to last revision by M0x0n
Tag: Rollback
 
Line 4: Line 4:


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

Latest revision as of 06:29, 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, 
	} )
	:addImage( args.image, args.caption )
	:addRow( 'Also Known As', args.foo )
	:addHeader( 'Social Media Links' )
	:addRow( 'Links', args.bar )
    :addHeader( 'Status' )
    :addRow( 'Current Status', args.sta )
	return retval
end

return p