From Wikipedia, the free encyclopedia
Jump to: navigation, search
Documentation icon Module documentation[view] [edit] [history] [purge]

This module is intended to be a replacement for {{WPBannerMeta}}.


Place the following on the template page:


After saving (or while previewing) the page, follow the link in the documentation box to configure it. Consider adding a pointer to the banner's configuration module inside an HTML-style comment: <!-- see [[Module:WikiProjectBanner/config/BANNER_NAME]] for banner configuration -->

Technical details[edit]

This module uses the following pages:

All subpages of this module:

--                               WikiProjectBanner                           --
--                                                                           --
-- This module produces templates used by WikiProjects to track pages that   --
-- are within their scope.                                                   --
-- Load modules that are needed every time.
local mShared = require('Module:WikiProjectBanner/shared')
local Banner = require('Module:WikiProjectBanner/Banner')
-- Lazily load modules that are not always needed.
local Assessment
local p = {}
function p._main(bannerName, args, cfg)
	-- Entry point from Lua.
	cfg = cfg or mw.loadData('Module:WikiProjectBanner/config')
	local success, bannerObj = pcall(, bannerName, args, cfg)
	if not success then
		return string.format(
			'<strong class="error">Error: %s</strong>',
			bannerObj -- This is the error message.
	return tostring(bannerObj)
function p.main(frame)
	-- Entry point from wikitext.
	-- Get the banner name.
	local parent = frame:getParent()
	local bannerName, isTemplate = parent:getTitle():gsub('^Template:', '')
	bannerName = bannerName:gsub('/sandbox$', '')
	isTemplate = isTemplate > 0
	-- Get the arguments.
	local args = {}
	for k, v in pairs(parent.args) do
		v = v:match('^%s*(.-)%s*$') -- Trim whitespace.
		if v ~= '' then
			args[k] = v
	-- Subst check.
	-- This must be done before any errors can be produced, otherwise the red
	-- "script error" text will be substituted instead of the template code.
	if mw.isSubsting() then
		local ret = {}
		ret[#ret + 1] = bannerName
		for k, v in pairs(args) do
			ret[#ret + 1] = k .. '=' .. v
		return '{{' .. table.concat(ret, '|') .. '}}'
	-- Check we are being invoked from a template.
	if not isTemplate then
		error('this module must be invoked from within a template')
	return p._main(bannerName, args)
return p