mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-02 08:35:14 -07:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a9064563da | ||
|
|
ec51438100 | ||
|
|
e91b0caabf | ||
|
|
eaa6729da0 | ||
|
|
071abd71d9 | ||
|
|
d35db9631e |
@@ -298,7 +298,12 @@ module Liquid
|
|||||||
end
|
end
|
||||||
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 = '')
|
def replace(input, string, replacement = '')
|
||||||
input.to_s.gsub(string.to_s, replacement.to_s)
|
input.to_s.gsub(string.to_s, replacement.to_s)
|
||||||
end
|
end
|
||||||
@@ -323,12 +328,22 @@ module Liquid
|
|||||||
output
|
output
|
||||||
end
|
end
|
||||||
|
|
||||||
# remove a substring
|
# @public_docs
|
||||||
|
# @syntax {{ string | remove: string }}
|
||||||
|
# @summary Removes a substring.
|
||||||
|
# @type filter
|
||||||
|
# @category string
|
||||||
|
# @return string
|
||||||
def remove(input, string)
|
def remove(input, string)
|
||||||
replace(input, string, '')
|
replace(input, string, '')
|
||||||
end
|
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)
|
def remove_first(input, string)
|
||||||
replace_first(input, string, '')
|
replace_first(input, string, '')
|
||||||
end
|
end
|
||||||
@@ -350,7 +365,12 @@ module Liquid
|
|||||||
InputIterator.new(input, context).concat(array)
|
InputIterator.new(input, context).concat(array)
|
||||||
end
|
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)
|
def prepend(input, string)
|
||||||
string.to_s + input.to_s
|
string.to_s + input.to_s
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user