VOOZH about

URL: https://en.wikipedia.org/wiki/Module:Main_if_exists

⇱ Module:Main if exists - Wikipedia


Jump to content
From Wikipedia, the free encyclopedia
👁 Image
Module documentation
[view] [edit] [history] [purge]
👁 Image
This module depends on the following other modules:

Usage

Used by Template:Main if exists

{{#invoke:Main if exists| main}}

--[[ v1.0
]]
localp={}
localyesno=require("Module:yesno")
functionp.main(frame)
localrawpages={}
localnvalid=0
localnamespace=frame.args.ns
fori,vinipairs(frame:getParent().args)do
if(v~=nil)then
localthisArg=mw.text.trim(v)
if(thisArg~="")then
localtitle=mw.title.new(thisArg,namespace)
iftitle~=nilandtitle.existsthen
table.insert(rawpages,title.fullText)
nvalid=nvalid+1
end
end
end
end
if(nvalid==0)then
ifyesno(frame.args.warning)then
ifnamespace==nilthen
namespace="page"
elseifnamespace:sub(-1)=="y"then
namespace=namespace:sub(0,-2).."ie"
end
mw.addWarning(string.format("'''[[%s]] — no output, because none of the %ss currently exist.'''",
frame:getParent():getTitle(),namespace))
end
return""
end
localmLabelledList=require('Module:Labelled list hatnote')
localpages=mLabelledList._labelledList(rawpages,"Main","")
returnpages
end
returnp