Module:Infocard

From Path of Exile 2 Wiki
Revision as of 00:09, 23 February 2016 by Vinifera7 (talk | contribs) (Created page with "local p = {} local getArgs function p.main(frame) if not getArgs then getArgs = require('Module:Arguments').getArgs end local args = getArgs(frame, { wrappers = 'Templ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Module documentation[view] [edit] [history] [purge]


Lua logo

This module depends on the following other modules:

This module implements {{infocard}}.

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'
	})
	return p._main(args)
end

function p._main(args)
	local container = mw.html.create('div')
		:attr('class', 'infocard ' .. args.class)
	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 i = 1
	while args[i] do
		inner:tag('div')
			:attr('class', 'block')
			:wikitext(args[i])
			:done()
		i = i + 1
	end
	container:node('inner')
	
	return tostring(container)
end

return p