Module:Sandbox/Nihiltres/Testing: Difference between revisions

Content deleted Content added
A convenience for later testing, now that I've done testing via preview :P
 
m Changed default test class to "unassessed"
 
(4 intermediate revisions by the same user not shown)
Line 2:
 
function p.main (frame)
local foo = 'Result of tested Lua snippet would be here.'
local bar = mw.loadData('Module:Class/importDefinitions')
returnVal = foo
local foo = mw.html.create("td")
if type(returnVal) == 'table' then
local dtc = "unassessed" --default test class
function tableRender (tbl, level)
local class = bar[frame.args[1] or dtc] or bar[dtc]
level = level or 0
local styleBasics = "text-align: center; font-weight: bold; "
--maxLevel avoids recursive issues; adjust as needed
foo:attr(
maxLevel = 4
"style",
if level > maxLevel then return tostring(tbl) end
styleBasics .. string.format("background-color: %s;", class.colour)
tab = ''
)
for i = 1, (level * 4) do tab = tab .. " " end
local img = class.icon.default and string.format(
local text = ''
"[[File:%s|16px|%s|link=|alt=]] ",
for k,v in pairs(tbl) do
class.icon.file,
if v == tbl then return tostring(tbl) end
class.labels.full
text = text..'\n\n'..tab..k..":"
) or ""
if type(v) == 'table' then
local link = string.format(
text = text .. tableRender(tbl, level + 1)
"[[:%s|%s]]",
else
class.category,
text = text..v
class.labels.short
end
)
end
foo:wikitext(img, link)
return textfoo
end
--return tableRendermw.dumpObject(returnValfoo)
else
return tostring(returnVal)
end
end