Module:Sandbox/Certes
Appearance
local p = {}
-- main(pagename, truevalue, falsevalue) indicates whether a page exists.
-- If the named page exist, it returns truevalue
-- If the named page does not exist, it returns falsevalue
-- Unlike many checks, this function does NOT record the current page as
-- having a wikilink to or a transclusion of the checked page.
-- truevalue is optional. It defaults to true in Lua or "true" from a template.
-- falsevalue is optional. It defaults to nil in Lua or "" from a template.
function p._main(pagename, truevalue, falsevalue)
-- Find expiry date of edit protection on the named page
-- If the page exists, this is some non-empty string, even if unprotected
-- If the page doesn't exist, this is an empty string
-- THE NEXT LINE ACTUALLY DOES SOMETHING (the rest is boilerplate)
if mw.getCurrentFrame():callParserFunction('PROTECTIONEXPIRY', "edit", pagename) ~= "" then
return truevalue
else
return falsevalue
end
end -- of p._main
function p.main(frame)
-- Take parameters out of the frame and pass them to p._main(). Return the result.
return p._main(frame.args[1], -- name of page whose existence is checked, e.g. "Talk:Foo"
frame.args[2] or true, -- value to return if page is present, default: the Lua boolean true
frame.args[3] or nil) -- value to return if page is absent, default: the Lua nil
end -- of p.main
return p