Module:Test2

From Elwiki
Revision as of 20:28, 25 April 2023 by Ritsu (talk | contribs)

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

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

function p.Patch(frame)
    local args = getArgs(frame)

    local input_args = split(mw.text.unstrip(args.orig), '|')
    local old_args = {}
    for k, v in ipairs(input_args) do
        local old_arg = split(v, '=')
        if not old_arg[2] then
            old_args[k] = v
        else
            old_args[old_arg[1]] = old_arg[2]
        end
    end

    args.orig = nil
    local new_args = table.deep_copy(old_args)

    for k, v in pairs(args) do
        if args[k] then
            new_args[k] = args[k]
        end
    end

    if args.dump then
        return inspect_dump(frame, new_args)
    end

    local old_table = frame:expandTemplate{
        title = 'Damage',
        args = old_args
    }

    local new_table = frame:expandTemplate{
        title = 'Damage',
        args = new_args
    }

    local tabber = frame:expandTemplate{
        title = 'Tabber',
        NA = '123',
        ['KR (' .. args.date .. ' Patch)'] = '456'
    }

    return frame:preprocess('{{Tabber|apple=pie}}')
  
end

return p