haml-edge 3.1.56 → 3.1.57
Sign up to get free protection for your applications and to get access to all the features.
- data/EDGE_GEM_VERSION +1 -1
- data/VERSION +1 -1
- data/lib/haml/precompiler.rb +12 -4
- data/test/haml/engine_test.rb +66 -0
- metadata +2 -2
data/EDGE_GEM_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.
|
1
|
+
3.1.57
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.
|
1
|
+
3.1.57
|
data/lib/haml/precompiler.rb
CHANGED
@@ -248,12 +248,20 @@ END
|
|
248
248
|
# It's important to preserve tabulation modification for keywords
|
249
249
|
# that involve choosing between posible blocks of code.
|
250
250
|
if %w[else elsif when].include?(keyword)
|
251
|
-
|
251
|
+
# Whether a script block has already been opened immediately above this line
|
252
|
+
was_opened = @to_close_stack.last && @to_close_stack.last.first == :script
|
253
|
+
if was_opened
|
254
|
+
@dont_indent_next_line, @dont_tab_up_next_text = @to_close_stack.last[1..2]
|
255
|
+
end
|
252
256
|
|
253
257
|
# when is unusual in that either it will be indented twice,
|
254
|
-
# or the case won't have created its own indentation
|
255
|
-
if
|
256
|
-
|
258
|
+
# or the case won't have created its own indentation.
|
259
|
+
# Also, if no block has been opened yet, we need to make sure we add an end
|
260
|
+
# once we de-indent.
|
261
|
+
if !was_opened || keyword == "when"
|
262
|
+
push_and_tabulate([
|
263
|
+
:script, @dont_indent_next_line, @dont_tab_up_next_text,
|
264
|
+
!was_opened])
|
257
265
|
end
|
258
266
|
elsif block || text =~ /^-\s*(case|if)\b/
|
259
267
|
push_and_tabulate([:script, @dont_indent_next_line, @dont_tab_up_next_text])
|
data/test/haml/engine_test.rb
CHANGED
@@ -697,6 +697,72 @@ HTML
|
|
697
697
|
HAML
|
698
698
|
end
|
699
699
|
|
700
|
+
def test_case_assigned_to_var
|
701
|
+
assert_equal(<<HTML, render(<<HAML))
|
702
|
+
bar
|
703
|
+
HTML
|
704
|
+
- var = case 12
|
705
|
+
- when 1; "foo"
|
706
|
+
- when 12; "bar"
|
707
|
+
= var
|
708
|
+
HAML
|
709
|
+
|
710
|
+
assert_equal(<<HTML, render(<<HAML))
|
711
|
+
bar
|
712
|
+
HTML
|
713
|
+
- var = case 12
|
714
|
+
- when 1
|
715
|
+
- "foo"
|
716
|
+
- when 12
|
717
|
+
- "bar"
|
718
|
+
= var
|
719
|
+
HAML
|
720
|
+
|
721
|
+
assert_equal(<<HTML, render(<<HAML))
|
722
|
+
bar
|
723
|
+
HTML
|
724
|
+
- var = case 12
|
725
|
+
- when 1
|
726
|
+
- "foo"
|
727
|
+
- when 12
|
728
|
+
- "bar"
|
729
|
+
= var
|
730
|
+
HAML
|
731
|
+
end
|
732
|
+
|
733
|
+
def test_if_assigned_to_var
|
734
|
+
assert_equal(<<HTML, render(<<HAML))
|
735
|
+
foo
|
736
|
+
HTML
|
737
|
+
- var = if false
|
738
|
+
- else
|
739
|
+
- "foo"
|
740
|
+
= var
|
741
|
+
HAML
|
742
|
+
|
743
|
+
assert_equal(<<HTML, render(<<HAML))
|
744
|
+
foo
|
745
|
+
HTML
|
746
|
+
- var = if false
|
747
|
+
- elsif 12
|
748
|
+
- "foo"
|
749
|
+
- elsif 14; "bar"
|
750
|
+
- else
|
751
|
+
- "baz"
|
752
|
+
= var
|
753
|
+
HAML
|
754
|
+
|
755
|
+
assert_equal(<<HTML, render(<<HAML))
|
756
|
+
foo
|
757
|
+
HTML
|
758
|
+
- var = if false
|
759
|
+
- "bar"
|
760
|
+
- else
|
761
|
+
- "foo"
|
762
|
+
= var
|
763
|
+
HAML
|
764
|
+
end
|
765
|
+
|
700
766
|
# HTML escaping tests
|
701
767
|
|
702
768
|
def test_ampersand_equals_should_escape
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haml-edge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.57
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Weizenbaum
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2010-08-
|
14
|
+
date: 2010-08-03 00:00:00 -04:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|