Jump to content

Module:Lua banner

विकिपिडिया नं

This module implements the {{lua}} template.

Usage from wikitext

[सम्पादन]

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

[सम्पादन]

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)

The args variable 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.



-- 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().argslocalargs={}fork,vinpairs(origArgs)dov=v:match('^%s*(.-)%s*$')ifv~=''thenargs[k]=vendendreturnp._main(args)endfunctionp._main(args)localmodules=mTableTools.compressSparseArray(args)localbox=p.renderBox(modules)localtrackingCategories=p.renderTrackingCategories(args,modules)returnbox..trackingCategoriesendfunctionp.renderBox(modules)localboxArgs={}if#modules<1thenboxArgs.text='<strong class="error">Error: no modules specified</strong>'elselocalmoduleLinks={}fori,moduleinipairs(modules)domoduleLinks[i]=string.format('[[:%s]]',module)endlocalmoduleList=mList.makeList('bulleted',moduleLinks)boxArgs.text='Uses [[Wikipedia:Lua|Lua]]:\n'..moduleListendboxArgs.type='notice'boxArgs.small=trueboxArgs.image='[[File:Lua-logo-nolabel.svg|30px|alt=Lua logo|link=Wikipedia:Lua]]'returnmMessageBox.main('mbox',boxArgs)endfunctionp.renderTrackingCategories(args,modules,titleObj)ifyesno(args.nocat)thenreturn''endlocalcats={}-- Error categoryif#modules<1thencats[#cats+1]='Lua templates with errors'end-- Lua templates categorytitleObj=titleObjormw.title.getCurrentTitle()localsubpageBlacklist={doc=true,sandbox=true,sandbox2=true,testcases=true}iftitleObj.namespace==10andnotsubpageBlacklist[titleObj.subpageText]thenlocalcategory=args.categoryifnotcategorythenlocalcategories={['Module:String']='Lua String-based templates',['Module:Math']='Templates based on the Math Lua module',['Module:BaseConvert']='Templates based on the BaseConvert Lua module',['Module:Citation']='Lua-based citation templates'}categories['Module:Citation/CS1']=categories['Module:Citation']category=modules[1]andcategories[modules[1]]category=categoryor'Lua-based templates'endcats[#cats+1]=categoryendfori,catinipairs(cats)docats[i]=string.format('[[Category:%s]]',cat)endreturntable.concat(cats)endreturnp
close