Jump to content

Module:Ustring/sandbox

From Wikipedia, the free encyclopedia
require('strict')returnsetmetatable({},{__index=function(t,k)localwhat=mw.ustring[k]iftype(what)~="function"thenreturnwhatendreturnfunction(frame)localfargs=frame.argslocalfargsused={tag=true,onerror=true}localargs={}localstr_i=1whilefargs['s'..str_i]dofargsused['s'..str_i]=trueargs[str_i]=fargs['s'..str_i]str_i=str_i+1endfori,vinipairs(fargs)dofargsused[i]=trueargs[i+str_i-1]=tonumber(v)orv:gsub("^\\","",1)endlocalresult=niliffargs.onerrorthenlocalsuccesssuccess,result=pcall(what,unpack(args))ifnotsuccessthenreturnfargs.onerrorendelseresult=what(unpack(args))endifnotfargs.tagthenreturnresultendlocaltagargs={}forx,yinpairs(fargs)doifnotfargsused[x]thentagargs[x]=yendendreturnframe:extensionTag{name=fargs.tag,content=result,args=tagargs}endend})
close