Jump to content

Module:Country check

විකිපීඩියා වෙතින්
local p = {}

local yesno = require('Module:Yesno')
local data = mw.loadData("Module:Country/data")

function p.main(frame)
    local new_args = p._getParameters(frame.args, {'s', 'of'})
    local s = new_args['s'] or ''
    local of = new_args['of'] or ''

    -- Check for prefix and suffix in the first input (s)
    local prefix = frame.args['prefix'] or ''
    local suffix = frame.args['suffix'] or ''

    if (prefix == '' or suffix == '') then
        -- If either prefix or suffix is unassigned, return the second input
        return of
    else
        -- Otherwise, return the first input
        return frame:expandTemplate{ title ='ConvertToAe',args={data[s]}}
    end
end
--[[ 
Helper function for parameter retrieval. 
]]
function p._getParameters(frame_args, arg_list)
    local new_args = {}
    local index = 1
    local value
    for _, arg in ipairs(arg_list) do
        value = frame_args[arg]
        if value == nil then
            value = frame_args[index]
            index = index + 1
        end
        new_args[arg] = value
    end
    return new_args
end

return p
"https://si.wikipedia.org/w/index.php?title=Module:Country_check&oldid=720582" වෙතින් සම්ප්‍රවේශනය කෙරිණි