Use replacement string for replace filters literally (#924)

This commit is contained in:
Dylan Thacker-Smith
2017-08-28 11:51:20 -04:00
committed by GitHub
parent 44eaa4b9d8
commit 27c91203ab
2 changed files with 6 additions and 2 deletions
+4 -2
View File
@@ -201,12 +201,14 @@ module Liquid
# Replace occurrences of a string with another
def replace(input, string, replacement = ''.freeze)
input.to_s.gsub(string.to_s, replacement.to_s)
replacement = replacement.to_s
input.to_s.gsub(string.to_s) { replacement }
end
# Replace the first occurrences of a string with another
def replace_first(input, string, replacement = ''.freeze)
input.to_s.sub(string.to_s, replacement.to_s)
replacement = replacement.to_s
input.to_s.sub(string.to_s) { replacement }
end
# remove a substring