Module:Sandbox/Nihiltres/Testing

This is the current revision of this page, as edited by Nihiltres (talk | contribs) at 23:34, 15 December 2016 (Changed default test class to "unassessed"). The present address (URL) is a permanent link to this version.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
p = {}

function p.main (frame)
	local foo = 'Result of tested Lua snippet would be here.'
	
	local bar = mw.loadData('Module:Class/importDefinitions')
	local foo = mw.html.create("td")
	local dtc = "unassessed" --default test class
	local class = bar[frame.args[1] or dtc] or bar[dtc]
	local styleBasics = "text-align: center; font-weight: bold; "
	foo:attr(
		"style",
		styleBasics .. string.format("background-color: %s;", class.colour)
	)
	local img = class.icon.default and string.format(
			"[[File:%s|16px|%s|link=|alt=]] ",
			class.icon.file,
			class.labels.full
		) or ""
	local link = string.format(
		"[[:%s|%s]]",
		class.category,
		class.labels.short
	)
	foo:wikitext(img, link)
	return foo
	--return mw.dumpObject(foo)
end

return p