Don't throw errors when text is nested within comments.

Closes gh-384.
This commit is contained in:
Nathan Weizenbaum 2011-05-10 15:27:13 -07:00
parent 10109d4eb1
commit 887d504757
3 changed files with 17 additions and 1 deletions

View File

@ -8,6 +8,8 @@
* If the ActionView `#capture` helper is used in a Haml template but without any Haml being run in the block, * If the ActionView `#capture` helper is used in a Haml template but without any Haml being run in the block,
return the value of the block rather than the captured buffer. return the value of the block rather than the captured buffer.
* Don't throw errors when text is nested within comments.
## 3.1.1 ## 3.1.1
* Update the vendored Sass to version 3.1.0. * Update the vendored Sass to version 3.1.0.

View File

@ -146,7 +146,7 @@ END
@tab_up = nil @tab_up = nil
process_line(@line.text, @line.index) unless @line.text.empty? || @haml_comment process_line(@line.text, @line.index) unless @line.text.empty? || @haml_comment
if block_opened? || @tab_up if @parent.type != :haml_comment && (block_opened? || @tab_up)
@template_tabs += 1 @template_tabs += 1
@parent = @parent.children.last @parent = @parent.children.last
end end

View File

@ -382,6 +382,20 @@ SOURCE
assert_equal("<p foo='bar'></p>\n", render('%p{:foo => "bar"}', :attr_wrapper => nil)) assert_equal("<p foo='bar'></p>\n", render('%p{:foo => "bar"}', :attr_wrapper => nil))
end end
def test_comment_with_crazy_nesting
assert_equal(<<HTML, render(<<HAML))
foo
bar
HTML
foo
-#
ul
%li{
foo
bar
HAML
end
# Regression tests # Regression tests
def test_whitespace_nuke_with_both_newlines def test_whitespace_nuke_with_both_newlines