Module:Ifexist
Appearance
| This module is rated as alpha. It is ready for limited use and third-party feedback. It may be used on a small number of pages, but should be monitored closely. Suggestions for new features or adjustments to input and output are welcome. |
This module implements {{If-exist}}, visit the template for documentation.
Usage
{{#invoke:Ifexist|main|[page name]|[then this]|[else this]}}
-- This module implements {{If-exist}}
-- optional if template {{If}} seems difficult to use
local p = {}
function p.main(frame)
title = frame.args[1] or '' -- PAGENAME
thenthis = frame.args[2] --THEN RETURN THIS
elsethis = frame.args[3] --ELSE THIS
if title.exists == true then
return thenthis
else
return elsethis
-- if title exists then return this, if title doesn't exist then this
end
if not title then
return error('Error at [[Template:If-exist]]: No page title found')
end
end
return p