Dota 2 Wiki
(Empty parameters are true instead of false in lua O.o)
m (Ok i'm just an idiot :/)
Line 37: Line 37:
 
n = n + 1
 
n = n + 1
 
end
 
end
  +
  +
infobox = infobox .. '|}'
 
 
 
return infobox
 
return infobox

Revision as of 19:43, 3 December 2017

Documentation for Module:Infobox Jump to code ↴ [ edit | purge ]

Reality Rift icon
▶️ Planeshift.
The documentation for this module can be found at Template:Infobox.
You may be forwarded to another wiki language, in case a translation is not available.


Dependencies

local p = {}

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

function p._main( args )
	local color = require('Module:Color').main
	local title_textcolor = args["title-textcolor"] or 'white'
	local title_background = args["title-bgcolor"] or color( 'wiki1' )
	local heading_textcolor = args["heading-textcolor"] or 'black'
	local heading_background = args["heading-bgcolor"] or '#EADCDA'
	
	local infobox = '{| class="infobox"\n| colspan="2" style="text-align:center; color:' .. title_textcolor .. '; background-color:' .. title_background .. ';" | <span style="font-weight:bold;">' .. args["title"] .. '</span>\n|-\n| colspan="2" style="text-align:center;"|\n|-\n'
	
	if args["image"] ~= '' or nil then
		local image_size = args["image-size"] or '256px'
		infobox = infobox .. '| colspan="2" | [[File:' .. args["image"] .. '|center|' .. image_size .. ']]\n|-\n'
	end
	
	local n = 1
	while args["trait" .. n] do
		if args["heading" .. n] then
			infobox = infobox .. '| colspan="2" style="text-align:center; color:' .. heading_textcolor .. '; background-color:' .. heading_background .. '" | <span style="font-weight:bold;">' .. args["heading" .. n] .. '</span>\n|-\n'
		end
		
		if args["trait" .. n] == 'fullwidth' then
			local style = args["stylevalue" .. n] or 'text-align:center;'
			infobox = infobox .. '| colspan="2" style="' .. style .. '" | ' .. args["value" .. n] .. '\n|-\n'
		else
			if args["value" .. n] ~= '' or nil then
				infobox = infobox .. '!' .. args['trait' .. n] .. ':\n| ' .. args["value" .. n] .. '\n|-\n'
			end
		end
		
		n = n + 1
	end

	infobox = infobox .. '|}'
	
	return infobox
end

return p