This module is rated as ready for general use. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing.
This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing.
This module is rated as ready for general use. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing.
This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing.
p={}localargslocalfunctioncallTemplate(template,targs)returnmw.getCurrentFrame():expandTemplate{title=template,args=targs}endlocalfunctiongetArgNums(prefix,suffix)-- Returns a table containing the numbers of the arguments that exist-- for the specified prefix and suffix.localnums={}localpattern='^'..prefix..'([1-9]%d*)'..suffix..'$'fork,vinpairs(args)dolocalnum=tostring(k):match(pattern)ifnumthennums[#nums+1]=tonumber(num)endendtable.sort(nums)returnnumsendlocalfunctiongetConstants()localconstantArgNums=getArgNums('pc','n')localconstantArgs={}for_,numinipairs(constantArgNums)dolocalkeyArg='pc'..tostring(num)..'n'localvalArg='pc'..tostring(num)..'v'localkey=args[keyArg]key=tonumber(key)orkeylocalvalue=args[valArg]constantArgs[key]=valueendreturnconstantArgsendlocalfunctiongetVariableVals()localvariableVals={}fori,vinipairs(args)doifi~=1thenvariableVals[i-1]=vendendreturnvariableValsendlocalfunction_main()localtemplate=args['call']or'void'localvariableParam=args.pvvariableParam=tonumber(variableParam)orvariableParamor1-- fix for positional parameterslocalvariableValPrefix=args.prefixor''localvariableValPostfix=args.postfixor''localsep=args[1]or''localconstantArgs=getConstants()localvariableVals=getVariableVals()localresult=''fori,vinipairs(variableVals)dov=mw.text.trim(v)-- trim whitespacelocaltargs=constantArgstargs[variableParam]=variableValPrefix..v..variableValPostfixresult=result..tostring(callTemplate(template,targs))ifvariableVals[i+1]thenresult=result..sependendreturnresultendfunctionp.main(frame)-- If called via #invoke, use the args passed into the invoking template.-- Otherwise, for testing purposes, assume args are being passed directly in.ifframe==mw.getCurrentFrame()thenargs=frame:getParent().argsfork,vinpairs(frame.args)doargs=frame.argsbreakendelseargs=frameendreturn_main()endreturnp