Compare commits

...
Author SHA1 Message Date
Dave Geddes a9064563da use consistent tense 2022-03-14 19:41:08 +00:00
Dave Geddes ec51438100 Document replace string filter 2022-03-14 19:33:44 +00:00
Dave Geddes e91b0caabf Document remove_first string filter 2022-03-14 19:26:26 +00:00
Dave Geddes eaa6729da0 document remove string filter 2022-03-14 19:22:07 +00:00
Dave Geddes 071abd71d9 use lowercase string category 2022-03-14 19:21:39 +00:00
Dave Geddes d35db9631e Document prepend string filter 2022-03-14 18:50:21 +00:00
+24 -4
View File
@@ -298,7 +298,12 @@ module Liquid
end
end
# Replace occurrences of a string with another
# @public_docs
# @syntax {{ string | replace: string, substring }}
# @summary Replaces all occurrences of a string with a substring.
# @type filter
# @category string
# @return string
def replace(input, string, replacement = '')
input.to_s.gsub(string.to_s, replacement.to_s)
end
@@ -323,12 +328,22 @@ module Liquid
output
end
# remove a substring
# @public_docs
# @syntax {{ string | remove: string }}
# @summary Removes a substring.
# @type filter
# @category string
# @return string
def remove(input, string)
replace(input, string, '')
end
# remove the first occurrences of a substring
# @public_docs
# @syntax {{ string | remove_first: string }}
# @summary Removes the first occurrences of a substring.
# @type filter
# @category string
# @return string
def remove_first(input, string)
replace_first(input, string, '')
end
@@ -350,7 +365,12 @@ module Liquid
InputIterator.new(input, context).concat(array)
end
# prepend a string to another
# @public_docs
# @syntax {{ string | prepend: string }}
# @summary Prepend a string to another string.
# @type filter
# @category string
# @return string
def prepend(input, string)
string.to_s + input.to_s
end