Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
Revision as of 08:54, 7 June 2024 by 1F616EMO (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

local p = {}

function p.main(frame)
    local args = require('Module:Arguments').getArgs(frame, {
        parentFirst = true,
        wrapper = {'Template:Exists'}
    })
    return p._main(args)
end

function p._main(args)
	local page = args[1] or ''
	local trueResult = args[2] or args['then'] or ''
	local falseResult = args[3] or args['else'] or ''
	
	if (p.checkExists(page)) then
		return trueResult
	else
		return falseResult
	end
end

function p.checkExists(page)
	page = mw.text.decode(page or '')
	local frame = mw.getCurrentFrame()
	if (page:match('[#<>%[%]%{%}]+') or page == '') then
		return false
	elseif (frame:callParserFunction('PROTECTIONEXPIRY:edit', page) ~= '') then
		return true
	else
		return false
	end
end

return p