Module:SMWUtil

From Leaguepedia | League of Legends Esports Wiki
Jump to: navigation, search

Documentation for this module may be created at Module:SMWUtil/doc

local bool_to_str = {
	[true] = 'Yes',
	[false] = 'No'
}

local p = {}

function p.subobject(name, data, prefix)
	if not data or not next(data) then return end
	if not prefix then prefix = '' end
	local subobject = {}
	for k, value in pairs(data) do
		if type(value) == 'table' then
			for _, v in ipairs(value) do
				subobject[#subobject+1] = prefix .. k .. '=' .. v
			end
		elseif type(value) == 'boolean' then
			subobject[#subobject+1] = prefix .. k .. '=' .. bool_to_str[value]
		else
			subobject[#subobject+1] = prefix .. k .. '=' .. value
		end
	end
	mw.getCurrentFrame():callParserFunction('#subobject:' .. name, subobject)
end		

return p