Module:IfEmpty: Difference between revisions

From Baldur's Gate 3 Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Tag: Reverted
Line 4: Line 4:
function p.main(frame)
function p.main(frame)
local args = getArgs(frame, {
local args = getArgs(frame, {
wrappers = 'Template:IfEmpty'
wrappers = 'Template:IfEmpty',
trim = true,
removeBlanks = true
})
})



Revision as of 00:22, 29 November 2023

This module implements the functionality of Template:IfEmpty. It returns the first template argument that's not empty or whitespace-only.


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

function p.main(frame)
	local args = getArgs(frame, {
		wrappers = 'Template:IfEmpty',
		trim = true,
		removeBlanks = true
	})

	for k,v in ipairs(args) do
		if v ~= '' then
			return v
		end
	end
end

return p