Jump to content

Module:Enumerate

From Wikipedia, the free encyclopedia

-- Enumerates a given parameter set from the invoking template as a bullet list.localgetArgs=require('Module:Arguments').getArgslocalyesno=require("Module:Yesno")localp={}functionp.main(frame)localargs=getArgs(frame,{frameOnly=true,trim=true})returnp._main(frame,args)endfunctionp._main(frame,args)localprefix=args[1]orargs["prefix"]or""localsuffix=args[2]orargs["suffix"]or""localparentArgs=frame:getParent()andgetArgs(frame:getParent(),{trim=true})orargslocalfinalOutput=""locallist=mw.html.create(yesno(args["ordered"])and"ol"or"ul")localcurrent=1localsearching=truewhilesearchingdolocalarg=(prefix==""andsuffix=="")andcurrentorprefix..tostring(current)..suffixifparentArgs[arg]thenlist:node(mw.html.create("li"):wikitext((args["pre"]or"")..parentArgs[arg]..(args["post"]or"")))current=current+1elsesearching=falseendendreturncurrent==1and""ortostring(list)endreturnp
close