FANDOM


-- Lua version of MW parser functions
-- Same behavior with better performance
 
-- Equivalent of #if:
-- {{ if | condition | if true | if false }}
local p = {}
local getArgs = require('Module:Arguments').getArgs
 
function p.ifNotEmpty(frame)
    local args = getArgs(frame)
    local retTrue = tostring(arg[2])
    local retFalse = tostring(arg[3])
 
	if args[1] ~= nil then
	    return mw.getCurrentFrame():preprocess(retTrue)
	else
	    return mw.getCurrentFrame():preprocess(retFalse)
	end
end
 
-- Equivalent of #ifeq:
-- {{ ifeq | string1 | string2 | if identical | if different }}
function p.ifEqual(frame)
    local args = getArgs(frame)
 
	if args[1] == args[2] then
	    return mw.getCurrentFrame():preprocess(args[3])
	else
	    return mw.getCurrentFrame():preprocess(args[4])
	end
end
 
return p