Module:Module sandbox: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Undid revision 1218890108 by Thisasia (talk)
Tags: Undo Mobile edit Mobile web edit Advanced mobile edit
No edit summary
Tags: Reverted Mobile edit Mobile web edit Advanced mobile edit
Line 4: Line 4:
local args = frame:getParent().args
local args = frame:getParent().args
local output = '{| class="infobox biography vcard" style="width: 22em;"\n'
local output = '{| class="infobox biography vcard" style="width: 22em;"\n'
local firstDescriptionFound = false
local descriptionFound = false
for key, value in pairs(args) do
for key, value in pairs(args) do
if not firstDescriptionFound and key:sub(1, 11) == 'description' then
if key:sub(1, 11) == 'description' and value ~= "" then
if value ~= "" then
output = '{| class="infobox biography vcard" style="width: 22em;"\n'
descriptionFound = true
output = output .. '| style="text-align: center; background-color: ' .. (args.descriptionbgcolor or "#f2f2f2") .. '; color: ' .. (args.descriptioncolor or "inherit") .. '; font-weight: bold;" | ' .. value .. '\n|-\n'
firstDescriptionFound = true
break
end
end
end
end
end
if args.image then
if not descriptionFound and args.image then
local imgc = args.imgc or ""
local imgc = args.imgc or ""
local imagesize = args.imagesize or ""
local imagesize = args.imagesize or ""
Line 21: Line 20:
end
end
for key, value in pairs(args) do
if firstDescriptionFound then
for key, value in pairs(args) do
if key:sub(1, 11) == 'description' and value ~= "" then
output = output .. '| style="text-align: center; background-color: ' .. (args.descriptionbgcolor or "#f2f2f2") .. '; color: ' .. (args.descriptioncolor or "inherit") .. '; font-weight: bold;" | ' .. value .. '\n|-\n'
if key:sub(1, 11) == 'description' and key ~= 'description' and key ~= 'descriptionbgcolor' and key ~= 'descriptioncolor' then
if value ~= "" then
elseif key ~= 'image' and key ~= 'imagecaption' and key ~= 'imgc' and key ~= 'imagesize' then
output = output .. '| style="text-align: center; background-color: ' .. (args.descriptionbgcolor or "#f2f2f2") .. '; color: ' .. (args.descriptioncolor or "inherit") .. '; font-weight: bold;" | ' .. value .. '\n|-\n'
output = output .. '| <b>' .. key .. '</b>\n| ' .. value .. '\n|-\n'
end
end
end
for key, value in pairs(args) do
if key ~= 'image' and key ~= 'imagecaption' and key ~= 'imgc' and key ~= 'imagesize' then
if key:sub(1, 11) ~= 'description' then
output = output .. '| <b>' .. key .. '</b>\n| ' .. value .. '\n|-\n'
end
end
end
end
end
end

Revision as of 13:33, 14 April 2024

local p = {}

function p.infobox(frame)
    local args = frame:getParent().args
    local output = '{| class="infobox biography vcard" style="width: 22em;"\n'
    local descriptionFound = false
    
    for key, value in pairs(args) do
        if key:sub(1, 11) == 'description' and value ~= "" then
            output = '{| class="infobox biography vcard" style="width: 22em;"\n'
            descriptionFound = true
            break
        end
    end
    
    if not descriptionFound and args.image then
        local imgc = args.imgc or ""
        local imagesize = args.imagesize or ""  
        output = output .. '|' ..'<div style="text-align:center;">'.. args.image.. '</div>'..'<small style="display: block; text-align: center;">' .. imgc .. '</small>\n|-\n'
    end
    
    for key, value in pairs(args) do
        if key:sub(1, 11) == 'description' and value ~= "" then
            output = output .. '| style="text-align: center; background-color: ' .. (args.descriptionbgcolor or "#f2f2f2") .. '; color: ' .. (args.descriptioncolor or "inherit") .. '; font-weight: bold;" | ' .. value .. '\n|-\n'
        elseif key ~= 'image' and key ~= 'imagecaption' and key ~= 'imgc' and key ~= 'imagesize' then
            output = output .. '| <b>' .. key .. '</b>\n| ' .. value .. '\n|-\n'
        end
    end
    
    output = output .. '|}\n'
    
    return output
end

return p