Module:IfEmpty: Difference between revisions

From bg3.wiki
Jump to navigation Jump to search
(Created page with "local p = {} function p.main(frame) local args = require('Module:Arguments').getArgs(frame, { wrappers = 'Template:If empty', removeBlanks = false }) for k,v in ipairs(args) do if v ~= '' then return v end end end return p")
 
No edit summary
Line 3: Line 3:
function p.main(frame)
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame, {
local args = require('Module:Arguments').getArgs(frame, {
wrappers = 'Template:If empty',  
wrappers = 'Template:IfEmpty',  
removeBlanks = false
removeBlanks = false
})
})

Revision as of 20:58, 5 March 2023

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


local p = {}

function p.main(frame)
	local args = require('Module:Arguments').getArgs(frame, {
		wrappers = 'Template:IfEmpty', 
		removeBlanks = false
	})

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

end

return p