Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/html2haml/html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,12 @@ def to_haml(tabs, options)
self.previous.content =~ /\A\s*\Z/ && self.previous.previous.nil?)
nuke_outer_whitespace = true
else
output << "= succeed #{self.next.content.slice!(/\A[^\s]+/).dump} do\n"
next_content = self.next.content
output << "= succeed #{next_content.slice!(/\A[^\s]+/).dump} do\n"
tabs += 1
output << tabulate(tabs)
#empty the text node since it was inserted into the block
self.next.content = ""
# Set the next content to whatever wasn't added to the succeed statement
self.next.content = next_content
end
end

Expand Down
15 changes: 15 additions & 0 deletions test/html2haml_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,21 @@ def test_comma_post_tag_with_text_before
HTML
end

def test_comma_doesnt_nuke_other_content_post_tag
assert_equal(<<HAML.rstrip, render(<<HTML))
#foo
Batch
= succeed "," do
%span Foo
and everything else that goes in here.
HAML
<div id="foo">
Batch
<span>Foo</span>, and everything else that goes in here.
</div>
HTML
end

def test_haml_tags_should_be_on_new_line_after_tag_with_blank_content
xml = "<weight> </weight>\n<pages>102</pages>"
haml = "%weight\n%pages 102"
Expand Down