Module:Switch

--Replaces the ineficient parser function -- Demo module --Syntax - where option is any string to match and caseX any key-value pairs --Syntax2  -> bcd -- local frame = {args = { '1',['#default']=8, 5 },getParent = function local pArgs = {'1',['src']=8, 5 }  return { args = pArgs } end } mw.log('') local p = {} local u = require('Dev:Utility') function p.main(frame) local tArgLang = u.getArgs(frame) return p.switch(tArgLang) end function p.switch(tArgs) if tArgs then if tArgs[1] and tArgs[1]~="" then local sCase = (tArgs[1].."" or "") sCase = mw.text.trim(sCase) if tonumber(sCase) then sCase = tonumber(sCase)+1 end if not(tArgs[sCase])then sCase = "#default" if tonumber(sCase) and sCase<2   then return "" end end return mw.getCurrentFrame:preprocess(tArgs[sCase] or "") else if (tArgs["#default"]) then return tArgs["#default"] or "" end end end end return p