Module:Data

From blackwiki
Revision as of 01:14, 28 October 2014 by blackwiki>MusikAnimal (Protected Module:Data: Highly visible template ([Edit=Allow only template editors and admins] (indefinite) [Move=Allow only template editors and admins] (indefinite)))
Jump to navigation Jump to search

This module allows wikitext to read values from data modules.

Usage

{{#invoke:Data|Module:ModuleName|key1|key2|key3|...}}

Read data value key1.key2.key3 from Module:ModuleName.


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)