Module:Table style/sandbox

local TableTools = require('Module:TableTools') local getArgs = require('Module:Arguments').getArgs local p = {}

local styles = mw.loadData('Module:Table style/styles') local aliases = mw.loadData('Module:Table style/aliases')

function p.main(frame) local args = getArgs(frame) return p._main(args) end

function p._main(args) local str = "" for _, arg in pairs(args) do		local name = arg if aliases[arg] ~= nil and aliases[arg] ~= '' then name = aliases[arg] end if styles[name] ~= nil and styles[name] ~= '' then str = str .. styles[name] else str = str .. arg .. ";"	   end end if str ~= '' then -- Only add attribute wrapper if any valid style codes were given. str = 'style="' .. str .. '"' end return str end

function p.supported_codes(frame) frame = mw.getCurrentFrame local t = mw.html.create('table') :addClass('wikitable') t:tag('tr') :tag('th'):wikitext('Code') :tag('th'):wikitext('Aliases') :tag('th'):wikitext('Output CSS Style') for k, v in TableTools.sortedPairs(raw_styles, function(a, b) return a < b end) do		local row = t:tag('tr') row:tag('td'):tag('code'):wikitext(k) local aliasList = frame:expandTemplate{ title = 'bulleted list', args = v.aliases }		row:tag('td'):wikitext(aliasList) row:tag('td'):tag('code'):wikitext(v.style) end return t end

return p