Modul:Message Box Templates

CamNet - das Wiki
Documentation icon Module documentation

This module implements template {{Message Box Templates}}.

Usage

{{#invoke:Message Box Templates|main}}


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

local tl = function(template)
	return '{{[[Template:' .. template .. '|' .. template .. ']]}}'
end

local messageBoxTemplates = {
	{
		template = 'Deprecated',
		description = 'articles that are outdated and are not maintained anymore.',
	}, {
		template = 'Deprecated template',
		description = 'outdated/deprecated templates and pages, that use these templates. <i>(used by template programmers)</i>',
	}, {
		template = 'Draft',
		description = 'articles/sections currectly in development or in revision.',
	}, {
		template = 'Faulty',
		description = 'articles/sections that are erroneous, faulty, or otherwise dangerous.',
	}, {
		template = 'Stub',
		description = 'articles that needs expanding.',
	}, {
		template = 'Template warning',
		description = 'the error feedback from templates. <i>(used by template programmers)</i>',
	}, {
		template = 'Untested',
		description = 'articles that lack validation and positive user feedback.',
	}, {
		template = 'Warning',
		description = 'Warning text.',
	}
}

function p.main(frame)
	local args = getArgs(frame)
	
	local envelopeMask, lineMask
	if args.type == 'dl' then
		envelopeMask = '<dl>\n%s</dl>\n'
		lineMask = '\t<dt>%s</dt>\n\t<dd>%s</dd>\n'
	else
		envelopeMask = '<ul>\n%s</ul>\n'
		lineMask = '\t<li>%s to mask <b>%s</b></li>\n'
	end

	local content = ''
	for _, t in ipairs(messageBoxTemplates) do
		content = content .. string.format(lineMask, tl(t.template), t.description)
	end
	return string.format(envelopeMask, content)
end

return p