Main | Documentation | Usage |
This Lua module is used on 16,404 pages, or on about 20.04% of all pages.
Edits to this Lua module will be widely noticed. To avoid large-scale disruption and unnecessary server load, any changes to this module should first be tested in its sandbox or testcases subpages. The tested changes can then be added to this page in one single edit by an admin or content moderator.
Please consider discussing any changes in the Discord server.
This module implements {{Exists}}.
-- Module copied from the Genshin Impact wiki
-- Revision as of 5-1-2023
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