mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-15 08:50:45 -07:00
Merge branch 'strip-html' of https://github.com/joliss/liquid into joliss-strip-html
Conflicts: lib/liquid/standardfilters.rb
This commit is contained in:
@@ -65,7 +65,7 @@ module Liquid
|
|||||||
end
|
end
|
||||||
|
|
||||||
def strip_html(input)
|
def strip_html(input)
|
||||||
input.to_s.gsub(/<script.*?<\/script>/, '').gsub(/<!--.*?-->/, '').gsub(/<.*?>/, '')
|
input.to_s.gsub(/<script.*?<\/script>/m, '').gsub(/<!--.*?-->/m, '').gsub(/<.*?>/m, '')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Remove all newlines from the string
|
# Remove all newlines from the string
|
||||||
@@ -73,7 +73,6 @@ module Liquid
|
|||||||
input.to_s.gsub(/\r?\n/, '')
|
input.to_s.gsub(/\r?\n/, '')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# Join elements of the array with certain character between them
|
# Join elements of the array with certain character between them
|
||||||
def join(input, glue = ' ')
|
def join(input, glue = ' ')
|
||||||
[input].flatten.join(glue)
|
[input].flatten.join(glue)
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ class StandardFiltersTest < Test::Unit::TestCase
|
|||||||
assert_equal 'test', @filters.strip_html("<div>test</div>")
|
assert_equal 'test', @filters.strip_html("<div>test</div>")
|
||||||
assert_equal 'test', @filters.strip_html("<div id='test'>test</div>")
|
assert_equal 'test', @filters.strip_html("<div id='test'>test</div>")
|
||||||
assert_equal '', @filters.strip_html("<script type='text/javascript'>document.write('some stuff');</script>")
|
assert_equal '', @filters.strip_html("<script type='text/javascript'>document.write('some stuff');</script>")
|
||||||
|
assert_equal 'test', @filters.strip_html("<div\nclass='multiline'>test</div>")
|
||||||
assert_equal '', @filters.strip_html(nil)
|
assert_equal '', @filters.strip_html(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user