Module:Data: Difference between revisions

Jump to navigation Jump to search
imported>Jackmcbarn
(create helper module to get values from a data module)
 
imported>Jackmcbarn
(redo how this works completely)
Line 1: Line 1:
local p = {}
local mt = {}


function p.main(frame)
function mt.__index(t, k)
local data
return function(frame)
for k, v in ipairs(frame.args) do
local data = mw.loadData(k)
if k == 1 then
for _,v in ipairs(frame.args) do
data = mw.loadData('Module:' .. v)
else
data = data[v]
data = data[v]
end
end
return data
end
end
return data
end
end


return p
return setmetatable({}, mt)

Revision as of 02:56, 7 October 2014

Documentation for this module may be created at Module:Data/doc

local mt = {}

function mt.__index(t, k)
	return function(frame)
		local data = mw.loadData(k)
		for _,v in ipairs(frame.args) do
			data = data[v]
		end
		return data
	end
end

return setmetatable({}, mt)