模組:沙盒/Gakmo/Test

local z = {}

function getCandidates( frame )
    local page = mw.title.new( frame.args.title ):getContent()
    local list = {}
    for n,m in mw.ustring.gmatch( page, frame.args.pattern ) do
        list[n] = m
    end
    return list
end

function z.count( frame )
    return #getCandidates( frame )
end

function z.result( frame )
    local result = getCandidates( frame )
    local linkprefix = frame.args.linkprefix
    local date = frame.args.date
    return frame:expandTemplate { title = linkprefix, args = { result[date] } }
end

return z