Přeskočit na obsah

Modul:DataAccess

Z Wikipedie, otevřené encyklopedie
require 'strict'

local p = {}

function p.get(frame)
	local i = 1
	local data = mw.loadData('Modul:' .. frame.args[i])
	local ret = data
	local arg
	while type(ret) == 'table' do
		i = i + 1
		arg = frame.args[i]
		ret = ret[tonumber(arg) or arg]
	end
	return ret
end

function p.getFromJSON(frame)
	local i = 1
	local data = mw.loadJsonData(frame.args[i])
	local ret = data
	local arg
	while type(ret) == 'table' do
		i = i + 1
		arg = frame.args[i]
		ret = ret[tonumber(arg) or arg]
	end
	return ret
end

return p