A large portion of relevant modules/templates have now been switched to cargo. Various usages of SMW throughout the wiki need to be replaced by the new functions, in particular item tables. If some pages do not show up but contain no errors, please null-edit them. To see how you can help with the port check out Path_of_Exile_Wiki:To-do_list/SMW_migration (and leave a comment on the talk page if you have questions).

Module:Infocard

From Path of Exile Wiki
Jump to: navigation, search

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

local p = {}
local getArgs

function p.main(frame)
	if not getArgs then
		getArgs = require('Module:Arguments').getArgs
	end
	local args = getArgs(frame, {
		wrappers = {
			'Template:Infocard',
			'Template:Infocard2'
		}
	})
	return p._main(args)
end

function p._main(args)
	local container = mw.html.create('div')
		:attr( 'class', 'infocard ' .. (args.class or '') )
	local topbar = mw.html.create('div')
		:attr('class', 'topbar')
	topbar
		:tag('div')
			:attr('class', 'left')
			:wikitext(args.headerleft)
			:done()
	local middle = mw.html.create('div')
		:attr('class', 'middle')
	middle
		:tag('div')
			:attr('class', 'header')
			:wikitext(args.header)
			:done()
	if args.subheader then
		middle
			:tag('div')
				:attr('class', 'subheader')
				:wikitext(args.subheader)
				:done()
	end
	topbar
		:node(middle)
	topbar
		:tag('div')
			:attr('class', 'right')
			:wikitext(args.headerright)
			:done()
	container
		:node(topbar)
	local inner = mw.html.create('div')
		:attr('class', 'inner')
	local block
	local i = 1
	while args[i] do
		block = mw.html.create('div')
			:attr( 'class', 'block ' .. (args[i .. 'class'] or '') )
		if type(args[i]) == 'table' then
			block:node(args[i])
		elseif type(args[i]) == 'string' then
			block:wikitext(args[i])
		end
		inner:node(block)
		i = i + 1
	end
	container:node(inner)
	return tostring(container)
end

return p