Jump to content

Module:Ifexist

From Wikipedia, the free encyclopedia
This is the current revision of this page, as edited by Codemini (talk | contribs) at 05:08, 23 May 2025 (I think the removal of mw.title.new caused a false statement when invoked onto a page). The present address (URL) is a permanent link to this version.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

-- 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 mw.title.new(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