Jump to content

Module:Ifexist

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Raph Williams65 (talk | contribs) at 21:42, 27 April 2025 (Works like #ifexist (magic word)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

-- This module implements {{Ifexist}}
 -- optional if template {{If}} seems difficult to use
local p = {}

function p.main(frame)
 title = frame.args[1] -- 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
end
return p