FANDOM


Line 6: Line 6:
 
function p.replace(frame)
 
function p.replace(frame)
 
text = frame.args[1]
 
text = frame.args[1]
string.gsub(text, "hello", "halo")
+
return string.gsub(text, "hello", "halo")
return text
 
 
end
 
end
   

Revision as of 02:34, 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|replace|text|pattern to remove|pattern to insert}}
 
local p = {}
 
function p.replace(frame)
    text = frame.args[1]
    return string.gsub(text, "hello", "halo")
end
 
return p
Community content is available under CC-BY-SA unless otherwise noted.