Module:MultiReplace/sandbox: Difference between revisions

Content deleted Content added
get arg 1 from parent
add unstrip option
 
(2 intermediate revisions by the same user not shown)
Line 3:
local function MultiReplace(args)
local input = args[1] or "{{{1}}}"
if args.unstrip == "yes" then input = mw.text.unstrip(input) end
local plain = args.plain == "yes"
 
Line 10 ⟶ 12:
local change = {pattern = args[i * 2], repl = args[i * 2 + 1]}
if not change.repl then
return tostringrequire(mw.html.create("strong")'Module:addClass(Error').error'){
:wikitext( 'MultireplaceMultiReplace: Unpaired argument: <code>' .. (i * 2) .. ' = ' .. change.pattern .. '</code>')
end}
)
end
changeList[i] = change
Line 45 ⟶ 47:
end
 
function p.main(frame, ...)
local args =
if type(frame.args) =~= 'table' thenand {frame, ...} or
if type(frame.args[1]) ~= 'table' and frame thenor
frame.args[1] =and frame.args or
args = frame:getParent().args
if args[1] == '' then
args[1] = frame:getParent().args[1]
end
else
args = frame:getParent().args
end
else
args = frame
end
return MultiReplace(args)
end