Allow 'end' to be followed by code for silent blocks.

This commit is contained in:
Nathan Weizenbaum 2009-08-27 23:01:56 -07:00
parent 9e354ac2bb
commit 2dc6832c42
3 changed files with 38 additions and 2 deletions

View File

@ -3,6 +3,17 @@
* Table of contents
{:toc}
## 2.2.4
Allow `end` to be used for silent script when it's followed by code.
For example:
- form_for do
...
- end if @show_form
This isn't very good style, but we're supporting it for consistency's sake.
## [2.2.3](http://github.com/nex3/haml/commit/2.2.3)
Haml 2.2.3 adds support for the JRuby bundling tools

View File

@ -398,8 +398,8 @@ END
end
# Closes a Ruby block.
def close_script
push_silent "end", true
def close_script(push_end = true)
push_silent("end", true) if push_end
@template_tabs -= 1
end

View File

@ -318,6 +318,31 @@ HTML
HAML
end
def test_silent_end_with_stuff
assert_equal(<<HTML, render(<<HAML))
e
d
c
b
a
HTML
- str = "abcde"
- if true
= str.slice!(-1).chr
- end until str.empty?
HAML
assert_equal(<<HTML, render(<<HAML))
<p>hi!</p>
HTML
- if true
%p hi!
- end if "foo".gsub(/f/) do
- "z"
- end + "bar"
HAML
end
def test_multiline_with_colon_after_filter
assert_equal(<<HTML, render(<<HAML))
Foo