🇮🇷 Iran Proxy | https://www.wikipedia.org/wiki/Module:Format_work/unsubst
Jump to content

Module:Format work/unsubst

From Wikipedia, the free encyclopedia

local function _isEmpty(value) return value == nil or value == '' end

local function _notEmpty(value) return not _isEmpty(value) end

local function _unnilify(value) return value or '' end

local function _alarmingMessage(message)
	return '<span class="error">[[Module:Format work/unsubst]] '..message..'.</span>'
	-- TODO ..'[[Category:Pages displaying alarming messages about Module:Format work/unsubst]]'
end

local function _main(args, body)
	if not mw.isSubsting() then
		return body or args.BODY or _alarmingMessage('is disembodied')
	end

	local label_distributor = ' |label= |distributor='
	if _notEmpty(args.label) then
		label_distributor = ' |label='..args.label
	elseif _notEmpty(args.distributor) then
		label_distributor = ' |distributor='..args.distributor
	end

	return '{{Format work'..
		' |act='..	_unnilify(args.act)..
		' |title='.._unnilify(args.title)..
		' |type='..	_unnilify(args.type)..
		label_distributor..
		' |year='..	_unnilify(args.year)..
		' |month='.._unnilify(args.month)..
		' |day='..	_unnilify(args.day)..
		' |notes='.._unnilify(args.notes)..
	'}}'
end

local p = {}

function p.main(frame, body)
	local args = require('Module:Arguments').getArgs(frame)
	if _isEmpty(args) then
		return _alarmingMessage('could not getArgs') -- This really would be alarming.
	end

	return _main(args, body)
end

return p