Module:Ifexist/sandbox
Jump to navigation
Jump to search
| File:Edit In Sandbox Icon - Color.svg | This is the module sandbox page for Module:Ifexist (diff). |
File:Test Template Info-Icon - Version (2).svg Module documentation[view] [edit] [history] [purge]
| File:Greek lc alpha icon.svg | 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
[edit source]{{#invoke:Ifexist|main|[page name]|[then this]|[else this]}}
--[[
Add your expirimental module code here
--]]
local p = {} -- represents p as a code for packages
function p.main(frame) -- package name = main, (frame) = global frame
title = frame.args[1] -- parameter 1
thenthis = frame.args[2] -- parameter 2
elsethis = frame.args[3] -- parameter 3
--[[
If this then return this else return this
--]]
if mw.title.new(title).exists == true then
return thenthis
else
return elsethis
end
--[[
You can use the magic word ({{#ifexist:title|thenthis|elsethis}})
--]]
end
return p