Module:Data

local p = {} function p.data( f ) local args = f:getParent.args local data = mw.loadData( 'Module:' .. args.data ) local value = data local case = args.lcase for k, v in ipairs( args ) do		v = mw.text.trim( v ) if case then v = mw.ustring.lower( v ) end value = value[v] if not value then return args.default or args[1] end end if type( value ) == 'table' then -- loadData tables don't work with table.concat local concatValue = {} for _, v in ipairs( value ) do			table.insert( concatValue, v ) end value = table.concat( concatValue, ( args.separator or '' ) .. ' ' ) end return value end

-- Trims all empty arguments, then invokes a module -- Parameters: --  1: the name of the module to invoke --  2: the function of the module --  everything else: gets trimmed and passed as arguments for the invoked module p.trimInvoke = function(frame) --local moduleName = frame.args[1]; --local moduleFunc = frame.args[2]; --frame.args[1]=nil; --frame.args[2]=nil; local newArgs = {}; for k, v in pairs( frame.args ) do		v = mw.text.trim( tostring( v ) ); if v ~= '' and v ~= nil then newArgs[k] = v;		end end --frame.args = newArgs; mw.logObject(newArgs); --return require('Module:'..moduleName)[moduleFunc](frame); local val, _ = string.gsub(frame:callParserFunction('#invoke', newArgs ), "%[%[Category:Articles with bad template parameters%]%]", ''); --Hack to remove category return val; end

return p