Module:Sandbox/Nihiltres/Testing: Difference between revisions

Content deleted Content added
Update with JSON-import test
More involved proof-of-concept
Line 2:
 
function p.main (frame)
local foo = 'Result of tested Lua snippet would be here.'
local bar = mw.loadData('Module:Sandbox/Nihiltres/Import')
foo = barmw.texthtml.create("table")
local td = foo:tag("td")
return mw.dumpObject(foo)
local dtc = "ga" --default test class
local class = bar[frame.args[1] or dtc] or bar[dtc]
local styleBasics = "text-align: center; font-weight: bold; "
td:attr(
"style",
styleBasics .. string.format("background-color: %s;", class.colour)
)
local img = class.iconDefault and string.format(
"[[File:%s|16px|%s|link=|alt=]] ", class.icon, class.labelFull
) or ""
local link = string.format(
"[[:%s|%s]]",
class.category,
class.labelShort
)
td:wikitext(img, link)
return foo
--return mw.dumpObject(foo)
end