Module:Sandbox/RexxS/Blacklist

From WikiProjectMed
Jump to navigation Jump to search
-- fragment to demo exact matching for field names in blacklist
-- #invoke Sandbox/RexxS/Blacklist
local p = {}
p.isBlacklisted = function(frame)
	local blacklist = frame.args.suppressfields or "aaa; bbb; other title 1; ccc; ddd"
	local fieldname = frame.args.name or "title"
	if blacklist then
		blacklisted = false
		for wrd in string.gmatch(blacklist, "[^,;]+") do
			if fieldname == mw.text.trim(wrd) then
				blacklisted = true
				break
			end
		end
		if blacklisted then
			return "blacklisted"
		else
			return "not blacklisted"
		end
	end
end
return p