Module:Sandbox/Certes
Appearance
local p = {}
-- Entry point for Lua callers
-- Returns a boolean value: is pagename the name of an existing page?
function p._exists(pagename)
-- Find expiry date of edit protection on the named page
-- If the page doesn't exist, this is an empty string
-- If the page exists, protected or not, this is some other value
-- Note: this check does NOT record a wikilink from the calling page to pagename
return mw.getCurrentFrame():callParserFunction('PROTECTIONEXPIRY', "edit", pagename) ~= ""
end
-- Entry point for template callers using #invoke:
function p.exists(frame)
-- args = { 1 = page name, 2 = text if exists, 3 = text if doesn't exist }
-- 2 and 3 are optional; by default we return a boolean suitable for use in Lua or modules
local args = frame.args
if p._exists(args[1]) then
return args[2] or true
else
return args[3] or nil
end
end
return p