Module:Sandbox/Aidan9382

This is an old revision of this page, as edited by Aidan9382 (talk | contribs) at 09:10, 27 September 2022 (indent test). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

require("Module:No globals")
local functions = {}

function functions.main(data)
	return "<div style=text-align:right;font-size:80%>This does nothing as of right now. "..os.time().."</div>"
end

function functions:namecall()
	return self
end

local function Dump(t,depth,result,indent,recursion)
	local depth = depth or 10
	local result = result or ""
	local indent = indent or 2
	local recursion = recursion or {}
	result = result .. "Dump start\n"
	for a,b in next,t do
		--Indent the table
		result = result .. "D"..string.rep(" ",indent)
		--Represent the key (we dont expand table keys)
		if type(a) == "string" then
			result = result .. "\""..a.."\""
		else
			result = result .. tostring(a)
		end
		result = result .. ": "
		--Represent the value
		if type(b) == "string" then
			result = result .. "\""..b.."\""
		elseif type(b) == "table" then
			if depth == 0 then
				result = result .. tostring(b) .. "[ Depth limit ]"
			elseif recursion[b] then
				result = result .. tostring(b) .. "[ Recursion ]"
			else --Dump the table inside
				recursion[b] = true
				result = result .. Dump(b,depth-1,result,indent+2,recursion)
			end
		elseif type(b) == "nil" then
			result = result .. "nil"
		else
			result = result .. tostring(b)
		end
		--Finalise line
		result = result .. "\n"
	end
	return result
end
function functions:RawInfo()
	return mw.html.create("syntaxhighlight"):wikitext(Dump(mw.html.create("syntaxhighlight"),5))
end

return functions