Module:Format work/unsubst
Appearance
| This module depends on the following other modules: |
This module is invoked by and only useful for {{format work}} |
Purpose
[edit]This module is only for use by {{format work}}, serving a similar function to Module:Unsubst, but correctly maintaining param order.
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