FANDOM


-- <nowiki>
 
local p = {}
 
-- groups many ifexist calls and returns the first hit, used in Template:Ingredients
function p.exists(frame)
    local basepagename = frame.args[1]
    local i = 2
    local n = select('#', frame.args)
    while (i < n) do
        local pagename = basepagename .. " " .. frame.args[i]
        if mw.title.new(pagename).exists then
            return pagename
        end
        i = i + 1 -- I hate you for not having ++
    end
    return basepagename
end
 
return p
 
--</nowiki>