[Haml] Don't remove \n in filters with interpolation.
This commit is contained in:
parent
c6135cf601
commit
58b3d67600
|
@ -8,6 +8,8 @@
|
|||
* Don't crash when `rake gems` is run in Rails with Haml installed.
|
||||
Thanks to [Florian Frank](http://github.com/flori).
|
||||
|
||||
* Don't remove `\n` in filters with interpolation.
|
||||
|
||||
## 2.2.22
|
||||
|
||||
[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.22).
|
||||
|
|
|
@ -100,7 +100,11 @@ module Haml
|
|||
if contains_interpolation?(text)
|
||||
return if options[:suppress_eval]
|
||||
|
||||
text = unescape_interpolation(text).gsub("\\n", "\n")
|
||||
text = unescape_interpolation(text).gsub(/(\\+)n/) do |s|
|
||||
escapes = $1.size
|
||||
next s if escapes % 2 == 0
|
||||
("\\" * (escapes - 1)) + "\n"
|
||||
end
|
||||
newline if text.gsub!(/\n"\Z/, "\\n\"")
|
||||
push_script <<RUBY.strip, :escape_html => false
|
||||
find_and_preserve(#{filter.inspect}.render_with_options(#{text}, _hamlout.options))
|
||||
|
|
|
@ -629,6 +629,15 @@ HAML
|
|||
assert_equal("<a href='#\"'></a>\n", render('%a(href="#\\"")'))
|
||||
end
|
||||
|
||||
def test_filter_with_newline_and_interp
|
||||
assert_equal(<<HTML, render(<<HAML))
|
||||
\\n
|
||||
HTML
|
||||
:plain
|
||||
\\n\#{""}
|
||||
HAML
|
||||
end
|
||||
|
||||
# HTML escaping tests
|
||||
|
||||
def test_ampersand_equals_should_escape
|
||||
|
|
Loading…
Reference in New Issue