Modul:Lua banner
Izgled
This module implements the {{lua}} template.
Usage from wikitext[uredi kôd]
This module cannot be used directly from wikitext. It can only be used through the {{lua}} template. Please see the template page for documentation.
Usage from Lua modules[uredi kôd]
To use this module from other Lua modules, first load the module.
localmLuaBanner=require('Module:Lua banner')
You can then generate a side box using the _main function.
mLuaBanner._main(args)
Theargsvariable should be a table containing the arguments to pass to the module. To see the different arguments that can be specified and how they affect the module output, please refer to the {{lua}} template documentation.
Tracking category[uredi kôd]
-- This module implements the {{lua}} template.
localyesno=require('Module:Yesno')
localmList=require('Module:List')
localmTableTools=require('Module:TableTools')
localmMessageBox=require('Module:Message box')
localp={}
functionp.main(frame)
localorigArgs=frame:getParent().args
localargs={}
fork,vinpairs(origArgs)do
v=v:match('^%s*(.-)%s*$')
ifv~=''then
args[k]=v
end
end
returnp._main(args)
end
functionp._main(args)
localmodules=mTableTools.compressSparseArray(args)
localbox=p.renderBox(modules)
localtrackingCategories=p.renderTrackingCategories(args,modules)
returnbox..trackingCategories
end
functionp.renderBox(modules)
localboxArgs={}
if#modules<1then
boxArgs.text='<strong class= "error" >Pogreška: nije određen modul</strong>'
else
localmoduleLinks={}
fori,moduleinipairs(modules)do
ifstring.find(module,"[Mm]odule?")==nilthen
module="Modul:"..module
end
moduleLinks[i]=string.format('[[:%s]]',module)
end
localmoduleList=mList.makeList('bulleted',moduleLinks)
if#moduleLinks>1
thenboxArgs.text='Koristi [[Wikipedia:Lua|Lua]] module:\n'..moduleList
elseboxArgs.text='Koristi [[Wikipedia:Lua|Lua]] modul:\n'..moduleList
end
end
boxArgs.type='notice'
boxArgs.small=true
boxArgs.image='[[File:Lua-logo-nolabel.svg|30px|alt=Lua logo|link=Wikipedia:Lua]]'
returnmMessageBox.main('mbox',boxArgs)
end
functionp.renderTrackingCategories(args,modules,titleObj)
ifyesno(args.nocat)then
return''
end
localcats={}
-- Error category
if#modules<1then
cats[#cats+1]='Lua predlošci s pogreškama'
end
-- Lua templates category
titleObj=titleObjormw.title.getCurrentTitle()
localsubpageBlacklist={
doc=true,
sandbox=true,
sandbox2=true,
testcases=true
}
iftitleObj.namespace==10
andnotsubpageBlacklist[titleObj.subpageText]
then
localcategory=args.category
ifnotcategorythen
category=categoryor'Lua predlošci'
end
cats[#cats+1]=category
end
fori,catinipairs(cats)do
cats[i]=string.format('[[Category:%s]]',cat)
end
returntable.concat(cats)
end
returnp