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

local maasa = mw.loadData("Module:තිථි මං සළකුණු/දත්ත").maasa

local function succession(frame, args)
    local bef = args["පෙර"]
	local aft = args["පසු"]
    local title = args["තිථිය"]

    local idxM = 0
    local valM = ""

    if title == nil then
        title = mw.title.getCurrentTitle()
    end

    if bef == nil then
        bef = "බක් අව තෙළෙස්වක"
    end
    if aft == nil then
        aft = "බක් අමාවක"
    end

    local s = title.text
    local items = mw.text.split( s, "%s+" )

    for k, v in pairs( maasa ) do
        -- process each key-value pair
        if items[1] == v then
            idxM = k
            valM = v
            break
        end
    end

    -- for k, v in pairs( items ) do
    --    -- process each key-value pair
    --    return v
    -- end

    -- local retVal = frame:expandTemplate("තිථි මං සළකුණු/පෙර-පසු-තිථි")
    local retVal = frame:expandTemplate{ title = 'තිථි මං සළකුණු/පෙර-පසු-තිථි', args = { bef, aft } }

	return retVal
end

function p.main(frame)
	local args = getArgs(frame)
	return p._main(frame, args)
end

function p._main(frame, args)
	return succession(frame, args)
end

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