mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
@@ -53,6 +53,11 @@ module Liquid
|
|||||||
wordlist.length > l ? wordlist[0..l].join(" ") + truncate_string : input
|
wordlist.length > l ? wordlist[0..l].join(" ") + truncate_string : input
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Split input string into an array of substrings separated by given pattern.
|
||||||
|
def split(input, pattern)
|
||||||
|
input.split(pattern)
|
||||||
|
end
|
||||||
|
|
||||||
def strip_html(input)
|
def strip_html(input)
|
||||||
input.to_s.gsub(/<script.*?<\/script>/, '').gsub(/<.*?>/, '')
|
input.to_s.gsub(/<script.*?<\/script>/, '').gsub(/<.*?>/, '')
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -39,6 +39,14 @@ class StandardFiltersTest < Test::Unit::TestCase
|
|||||||
assert_equal '1234567890', @filters.truncate('1234567890')
|
assert_equal '1234567890', @filters.truncate('1234567890')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_strip
|
||||||
|
assert_equal ['12','34'], @filters.split('12~34', '~')
|
||||||
|
assert_equal ['A? ',' ,Z'], @filters.split('A? ~ ~ ~ ,Z', '~ ~ ~')
|
||||||
|
assert_equal ['A?Z'], @filters.split('A?Z', '~')
|
||||||
|
# Regexp works although Liquid does not support.
|
||||||
|
assert_equal ['A','Z'], @filters.split('AxZ', /x/)
|
||||||
|
end
|
||||||
|
|
||||||
def test_escape
|
def test_escape
|
||||||
assert_equal '<strong>', @filters.escape('<strong>')
|
assert_equal '<strong>', @filters.escape('<strong>')
|
||||||
assert_equal '<strong>', @filters.h('<strong>')
|
assert_equal '<strong>', @filters.h('<strong>')
|
||||||
|
|||||||
Reference in New Issue
Block a user