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