Jump to content

Module:Historical affiliations

From Wikipedia, the free encyclopedia

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

function p.main(frame)
	local args = getArgs(frame)
	
	local floatClass = (args.float == 'left' and 'ha-float-left') or
		((args.float == 'none' and 'ha-float-none') or '')
	
	local container = mw.html.create('div')
		:addClass('historical-affiliation')
		:addClass(floatClass)
		
	if args.width then
		container:css('width', args.width)
	end
	
	local titleId = math.random()

	container:tag('div')
		:attr('id', titleId)
		:addClass('historical-affiliation-title')
		:wikitext(args.title and args.title or 'Historical affiliations')
		
	local list = container:tag('ul')
		:attr('aria-labelledby', titleId)
		:addClass('historical-affiliation-list')

	for _, val in ipairs(args) do
		list:tag('li'):wikitext(val)
	end

	return tostring(container) .. frame:extensionTag{
		name = 'templatestyles',
		args = { src = 'Template:Historical affiliations/styles.css' }
	}
end

return p