[Haml] Fix line-number-reporting with certain sorts of filters.
Closes gh-104
This commit is contained in:
parent
5db91850d7
commit
a02519e9ff
|
@ -12,6 +12,8 @@
|
|||
that return strings in Rails 3.
|
||||
This is [the same deprecation that exists in Rails 3](http://github.com/rails/rails/commit/9de83050d3a4b260d4aeb5d09ec4eb64f913ba64).
|
||||
|
||||
* Make sure line numbers are reported correctly when filters are being used.
|
||||
|
||||
## 2.2.21
|
||||
|
||||
[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.21).
|
||||
|
|
|
@ -100,8 +100,10 @@ module Haml
|
|||
if contains_interpolation?(text)
|
||||
return if options[:suppress_eval]
|
||||
|
||||
push_script <<RUBY, :escape_html => false
|
||||
find_and_preserve(#{filter.inspect}.render_with_options(#{unescape_interpolation(text)}, _hamlout.options))
|
||||
text = unescape_interpolation(text).gsub("\\n", "\n")
|
||||
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))
|
||||
RUBY
|
||||
return
|
||||
end
|
||||
|
@ -113,6 +115,10 @@ RUBY
|
|||
else
|
||||
push_text(rendered.rstrip)
|
||||
end
|
||||
|
||||
(text.count("\n") - 1).times {newline}
|
||||
resolve_newlines
|
||||
newline
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -189,7 +189,6 @@ END
|
|||
if flat?
|
||||
push_flat(@line)
|
||||
@line = @next_line
|
||||
newline
|
||||
next
|
||||
end
|
||||
|
||||
|
|
|
@ -80,6 +80,11 @@ MESSAGE
|
|||
"!!!\n\n bar" => ["Illegal nesting: nesting within a header command is illegal.", 3],
|
||||
"foo\n:ruby\n 1\n 2\n 3\n- raise 'foo'" => ["foo", 6],
|
||||
"foo\n:erb\n 1\n 2\n 3\n- raise 'foo'" => ["foo", 6],
|
||||
"foo\n:plain\n 1\n 2\n 3\n- raise 'foo'" => ["foo", 6],
|
||||
"foo\n:plain\n 1\n 2\n 3\n4\n- raise 'foo'" => ["foo", 7],
|
||||
"foo\n:plain\n 1\n 2\n 3\#{''}\n- raise 'foo'" => ["foo", 6],
|
||||
"foo\n:plain\n 1\n 2\n 3\#{''}\n4\n- raise 'foo'" => ["foo", 7],
|
||||
"foo\n:plain\n 1\n 2\n \#{raise 'foo'}" => ["foo", 5],
|
||||
"= raise 'foo'\nfoo\nbar\nbaz\nbang" => ["foo", 1],
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue