FANDOM


(Didn't work)
 
Line 1: Line 1:
  +
-- 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 = {}
 
local p = {}
   
 
function p.replace(frame)
 
function p.replace(frame)
-- Simple find-and-replace 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}}
 
 
text = frame.args[1]
 
text = frame.args[1]
 
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.convertEvidence(frame)
 
-- Replaces instances of dots with line breaks. Meant to be used on
 
-- Template:CaseData.
 
parent = frame:getParent()
 
text = parent.args[1]
 
new_text, _ = string.gsub(text, "&middot;", "<br>")
 
return p.replace(newFrame)
 
 
end
 
end
   

Latest revision as of 04:14, February 2, 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.