FANDOM


(I think this didn't work because of a typo)
(Never mind)
Line 8: Line 8:
 
new_text, _ = string.gsub(text, frame.args[2], frame.args[3])
 
new_text, _ = string.gsub(text, frame.args[2], frame.args[3])
 
return new_text
 
return new_text
end
 
 
function p.replaceFromTemplate(frame)
 
return p.replace(frame:getParent())
 
 
end
 
end
   

Revision as of 22:53, January 28, 2020

-- 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|replace|text|pattern to remove|pattern to insert}}
 
local p = {}
 
function p.replace(frame)
    text = frame.args[1]
    new_text, _ = string.gsub(text, frame.args[2], frame.args[3])
    return new_text
end
 
return p
 
--[[Category:Modules]]
Community content is available under CC-BY-SA unless otherwise noted.