Module:Generic header

From Uncyclopedia, the content-free encyclopedia
Jump to navigation Jump to search

local p = {}

function p.main(frame)
	local parent = frame:getParent()
	local args = parent and parent.args or frame.args

	local class = args.class
	if not class or class == '' then
		class = 'un-default-header'
	end

	local style = args.style or ''
	local title = args.title

	local out = {}

	-- Load TemplateStyles
	table.insert(out, frame:extensionTag{
		name = 'templatestyles',
		args = { src = 'Generic header/styles.css' }
	})

	-- Header wrapper
	table.insert(out,
		string.format(
			'<div class="generic-header %s"%s>',
			class,
			style ~= '' and (' style="' .. style .. '"') or ''
		)
	)

	-- Optional title
	if title and title ~= '' then
		table.insert(out,
			'<div class="generic-header-title">' .. title .. '</div>'
		)
	end

	-- Buttons
	table.insert(out, '<div class="generic-button-container">')

	for i = 1, 25 do
		local val = args[i]
		if val and val ~= '' then
			table.insert(out,
				'<div class="generic-button">' .. val .. '</div>'
			)
		end
	end

	table.insert(out, '</div></div>')

	return table.concat(out)
end

return p