localp={}functionp.main(frame)localargs=require('Module:Arguments').getArgs(frame,{removeBlanks=false})locallist=""ifargs[1]thenlist=mw.html.create('table')list:css("background-color","#ecfcf4")forn,cinipairs(args)doifc~=""thenlocalp="Template:Country data "..clocallinkifrequire('Module:Redirect').luaIsRedirect(p)thenlink="["..mw.title.new(p):fullUrl("redirect=no").." "..p.."]"elselink="[["..p.."]]"endlocalvar=args["var"..n]or""localvartext=var==""and""or" (<code>"..var.."</code> variant)"localnote=args["note"..n]or""localrow=list:tag("tr")row:tag("td"):css("padding","0px 10px"):addClass("plainlinks"):wikitext(link..vartext)row:tag("td"):css("padding","0px 10px"):wikitext(require("Module:Flagg").luaMain(frame,{"usc",c,variant=var}))row:tag("td"):css("padding","0px 10px"):wikitext(note)endendendlocalhead=""ifargs["header"]andargs["header"]~=""thenifargs["header"]=="related"thenhead="====Related templates====\nPlease see the following related <code>country_data</code> templates:"elseifstring.sub(args["header"],1,4)=="for:"thenhead="<code>Country_data</code> templates are also available for "..string.sub(args["header"],5,-1)..":"elsehead=args["header"]endendreturnhead..(head~=""andlist~=""and"\n"or"")..tostring(list)endreturnp