FANDOM


m
m
Line 6: Line 6:
 
function p.printList(frame)
 
function p.printList(frame)
 
params = frame:getParent().args
 
params = frame:getParent().args
return string.gsub(params[1], params[2], params[3])
+
text = params[1]
  +
return string.gsub(text, params[2], params[3])
 
end
 
end
   

Revision as of 00:08, December 8, 2019

-- Simple find-and-replace that can be used on text templates so that there's less of a need for instances of nearly identical text.
-- Usage: {{#invoke:replace|text|pattern to remove|pattern to insert}}
 
local p = {}
 
function p.printList(frame)
    params = frame:getParent().args
    text = params[1]
    return string.gsub(text, params[2], params[3])
end
 
return p
Community content is available under CC-BY-SA unless otherwise noted.