Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Replace

From Vault Hunters Official Wiki

See {{Replace}}.


local p = {}
function p.replace( f )
	local raw_args = f:getParent().args
	local args = require("Module:ProcessArgs").norm(raw_args)
	
	local text = args[1] or ''
	if text == '' then
		return text
	end
	
	-- loop through raw args so we keep empty replacements (like `|str=`) intact
	for k, v in pairs(raw_args) do
		if k ~= 1 then
			local value = args[k] or '' -- get normalised arg value
        	text = text:gsub(k, value)
        end
	end
	
	return text
end
return p