mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a9064563da | ||
|
|
ec51438100 | ||
|
|
e91b0caabf | ||
|
|
eaa6729da0 | ||
|
|
071abd71d9 | ||
|
|
d35db9631e |
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user