Module:Test: Difference between revisions

From Elwiki
No edit summary
Tag: Reverted
No edit summary
Tag: Reverted
Line 13: Line 13:
     end
     end
     infobox:addClass('infobox-' .. divclass);
     infobox:addClass('infobox-' .. divclass);
function spairs2(t)
    local keys = {}
    for k in pairs(t) do keys[#keys + 1] = k end
    table.sort(keys, function(a, b) return #a == #b and a < b or #a < #b end)
    local i = 0
    return function()
        i = i + 1
        return keys[i], t[keys[i]]
    end
end


local test='';
local test='';
     for k, v in spairs(args) do
     for k, v in spairs2(args) do
         if string.match(k, 'data[0-9]+') ~= nil then
         if string.match(k, 'data[0-9]+') ~= nil then
             local i = k:gsub('data', '');
             local i = k:gsub('data', '');

Revision as of 15:21, 17 June 2024

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

require('Module:CommonFunctions')
require('Module:InfoboxProto');
local getArgs = require('Module:Arguments').getArgs
local p = {}

-- Main process
function p.main(frame)
    local args = getArgs(frame);
    local infobox = require('Module:InfoboxProto').main(frame, args.title);
    local divclass = args.divclass;
    if divclass == nil then
        divclass = 'custom'
    end
    infobox:addClass('infobox-' .. divclass);

function spairs2(t)
    local keys = {}
    for k in pairs(t) do keys[#keys + 1] = k end
    table.sort(keys, function(a, b) return #a == #b and a < b or #a < #b end)
    local i = 0
    return function()
        i = i + 1
        return keys[i], t[keys[i]]
    end
end

local test='';
    for k, v in spairs2(args) do
        if string.match(k, 'data[0-9]+') ~= nil then
            local i = k:gsub('data', '');
test = test .. ' ' .. k;
            addField('data' .. i, args['label' .. i])
        end
    end
    
    --return tostring(infobox);
return test;

end

return p