-- This module implements the {{Uses TemplateStyles}} 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)localtStyles=mTableTools.compressSparseArray(args)localbox=p.renderBox(tStyles)localtrackingCategories=p.renderTrackingCategories(args,tStyles)returnbox..trackingCategoriesendfunctionp.renderBox(tStyles)localboxArgs={}if#tStyles<1thenboxArgs.text='<strong class="error">Error: no TemplateStyles specified</strong>'elselocaltStylesLinks={}fori,tsinipairs(tStyles)dolocalsandboxLink=nillocaltsTitle=mw.title.new(ts)iftsTitlethenlocaltsSandboxTitle=mw.title.new(string.format('%s:%s/sandbox/%s',tsTitle.nsText,tsTitle.baseText,tsTitle.subpageText))iftsSandboxTitleandtsSandboxTitle.existsthensandboxLink=string.format(' ([[:%s|sandbox]])',tsSandboxTitle.prefixedText)endendtStylesLinks[i]=string.format('[[:%s]]%s',ts,sandboxLinkor'')endlocaltStylesList=mList.makeList('bulleted',tStylesLinks)boxArgs.text='This '..(mw.title.getCurrentTitle():inNamespaces(828,829)and'module'or'template')..' uses [[Wikipedia:TemplateStyles|TemplateStyles]]:\n'..tStylesListendboxArgs.type='notice'boxArgs.small=trueboxArgs.image='[[File:Farm-Fresh css add.svg|32px|alt=CSS]]'returnmMessageBox.main('mbox',boxArgs)endfunctionp.renderTrackingCategories(args,tStyles,titleObj)ifyesno(args.nocat)thenreturn''endlocalcats={}-- Error categoryif#tStyles<1thencats[#cats+1]='Uses TemplateStyles templates with errors'end-- TemplateStyles categorytitleObj=titleObjormw.title.getCurrentTitle()localsubpageBlacklist={doc=true,sandbox=true,sandbox2=true,testcases=true}if(titleObj.namespace==10ortitleObj.namespace==828)andnotsubpageBlacklist[titleObj.subpageText]thenlocalcategory=args.categoryifnotcategorythencategory=categoryor'Templates using TemplateStyles'endcats[#cats+1]=categoryifnotyesno(args.noprotcat)thenlocalcurrentProt=titleObj.protectionLevels["edit"]andtitleObj.protectionLevels["edit"][1]ornillocaladdedLevelCat=falselocaladdedPadlockCat=falsefori,tsinipairs(tStyles)dolocaltsTitleObj=mw.title.new(ts)localtsProt=tsTitleObj.protectionLevels["edit"]andtsTitleObj.protectionLevels["edit"][1]orniliftsProt~=currentProtandnotaddedLevelCatthencats[#cats+1]="Templates using TemplateStyles with a different protection level"endiftsProtandnotaddedPadlockCatthenlocalcontent=tsTitleObj:getContent()ifnotcontent:find("{{pp-")thencats[#cats+1]="Templates using TemplateStyles without padlocks"addedPadlockCat=trueendendendendendfori,catinipairs(cats)docats[i]=string.format('[[Category:%s]]',cat)endreturntable.concat(cats)endreturnp