Module:Devmodule

-- //Invokes global modules from dev.wikia.com -- syntax -- local p ={} -- Creates a pseudo frame local pseudoFrame ={} function pseudoFrame.new (frame) local self = {} self.args = mw.clone(frame.args) function self:getParent return mw.clone(frame:getParent) end function self:preprocess(sWikiText) return frame:preprocess(sWikiText) end function self:expandTemplate(title,args) return frame:expandTemplate{ title,args} end function self:getArgument( arg ) return frame:getArgument( arg ) end function self:newParserValue ( arg ) return frame:newParserValue(arg) end function self:newTemplateParserValue (title,args) return frame:newTemplateParserValue{ title, args } end function self:argumentPairs return frame:argumentPairs end return self end function p.main(originalFrame) local sModuleName,sFunctionName local frame = pseudoFrame.new(originalFrame) local oFrameParent = frame:getParent local oFrameChildtab = frame local oFrameChild = oFrameChildtab.args if (oFrameParent and not(oFrameParent.args[1] )) and oFrameChild[1] then sModuleName= oFrameChild[1] if oFrameChild["#fname"] then sFunctionName = oFrameChild["#fname"] frame.args["#fname"] = nil end table.remove(frame.args,1) else if oFrameParent and oFrameParent.args[1] then tParentArgs = oFrameParent.args sModuleName= tParentArgs[1] table.remove(frame:getParent.args,1) if oFrameParent.args["#fname"] then sFunctionName = tParentArgs["#fname"] frame:getParent.args["#fname"] = nil end end end if type(sModuleName)=="string"then sModuleName= sModuleName:sub(1,1):upper .. sModuleName:sub(2) else return "" end local bStatus,sErr = pcall(loadModule,sModuleName,sFunctionName,frame) if not(bStatus) then local bModuleUnavailable = sErr:match("module.*("..sModuleName..").*not found") if (bModuleUnavailable) then return "`Module:".. sModuleName .."` doesn't exist in dev.wikia.com . Note: Module names are case-sensitive." else return sErr end else return sErr end end function loadModule(sModuleName,sFunctionName,frame) local globalModule = require("Dev:"..sModuleName) sFunctionName = sFunctionName or "main" if (sFunctionName) and globalModule[sFunctionName] then return globalModule[sFunctionName](frame) end end return p