Skip to content

Commit

Permalink
[Haml] Fix a bug with '- end if foo'.
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed Oct 8, 2009
1 parent bbca715 commit 13ff32e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions doc-src/HAML_CHANGELOG.md
Expand Up @@ -14,6 +14,9 @@
* Add `<code>` to the list of tags that's
{file:HAML_REFERENCE.md#preserve-option automatically whitespace-preserved}.

* Fixed a bug with `end` being followed by code in silent scripts -
it no longer throws an error when it's nested beneath tags.

## [2.2.6](http://github.com/nex3/haml/commit/2.2.6)

* Made the error message when unable to load a dependency for html2haml
Expand Down
2 changes: 1 addition & 1 deletion lib/haml/precompiler.rb
Expand Up @@ -228,7 +228,7 @@ def process_line(text, index)
newline_now

# Handle stuff like - end.join("|")
@to_close_stack.first << false if text =~ /^-\s*end\b/ && !block_opened?
@to_close_stack.last << false if text =~ /^-\s*end\b/ && !block_opened?

case_stmt = text =~ /^-\s*case\b/
block = block_opened? && !mid_block_keyword?(text)
Expand Down
18 changes: 18 additions & 0 deletions test/haml/engine_test.rb
Expand Up @@ -342,6 +342,24 @@ def test_end_with_method_call
HAML
end

def test_nested_end_with_method_call
assert_equal(<<HTML, render(<<HAML))
<p>
2|3|4
b-a-r
</p>
HTML
%p
= [1, 2, 3].map do |i|
- i + 1
- end.join("|")
= "bar".gsub(/./) do |s|
- s + "-"
- end.gsub(/-$/) do |s|
- ''
HAML
end

def test_silent_end_with_stuff
assert_equal(<<HTML, render(<<HAML))
e
Expand Down

0 comments on commit 13ff32e

Please sign in to comment.