Module:if empty
Appearance
- The following documentation is located at Module:if empty/documentation. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module implements {{if empty}}
.
-- Prevent substitution.
if mw.isSubsting() then
return require("Module:unsubst")
end
local export = {}
-- Do all the work via [[Module:parameters]], as it returns a list of parameters
-- with any gaps removed, treating blank parameters as gaps, so simply return
-- the first value, falling back to the empty string. Blank parameters are
-- (obviously) permitted, but missing ones are not (i.e. using named parameters
-- to specify non-contiguous numeric parameters like |1000=).
function export.main(frame)
return require("Module:parameters").process(frame:getParent().args, {
[1] = {list = true, disallow_missing = true}
})[1][1] or ""
end
return export