Jump to content

Module:If in category/sandbox: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
oops
oops again
 
Line 2: Line 2:


function p.main(frame)
function p.main(frame)
local args = require('Module:Arguments')getArgs(frame)
local args = require('Module:Arguments').getArgs(frame)
return p._main(args)
return p._main(args)
end
end

Latest revision as of 20:19, 5 March 2025

local p = {}

function p.main(frame)
	local args = require('Module:Arguments').getArgs(frame)
	return p._main(args)
end

function p._main(args)
	-- create a title object
	local page = (args.page and mw.title.new(args.page)) or mw.title.getCurrentTitle()
	if require('Module:TableTools').inArray(page.categories, string.gsub( args[1], '^[Cc]ategory:', '' )) then
		if not args[3] then
			-- if we are are not given anything to return, return 'yes' if it evalulates to true
    		return args[2] or 'yes'
    	else 
    		return args[2]
		end
	else
		return args[3]
	end
end

return p