Module:Sandbox/Was a bee/Dump

From blackwiki
< Module:Sandbox
Revision as of 17:07, 2 June 2018 by blackwiki>Was a bee
Jump to navigation Jump to search

→ See Template:Dump.



-- Copied from [[Module:Wikidata]]
require('Module:No globals')
local p = {}

function p.Dump(frame)
	local f = (frame.args[1] or frame.args.id) and frame or frame:getParent()
	local data = mw.wikibase.getEntityObject(f.args.id)
	if not data then
		return i18n.warnDump
	end

	local i = 1
	while true do
		local index = f.args[i]
		if not index then
			return "<pre>"..mw.dumpObject(data).."</pre>".. i18n.warnDump
		end

		data = data[index] or data[tonumber(index)]
		if not data then
			return i18n.warnDump
		end

		i = i + 1
	end
end

return p