haml-edge 3.1.68 → 3.1.69
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 +5 -3
- data/test/haml/engine_test.rb +2 -2
- metadata +1 -1
data/EDGE_GEM_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.
|
1
|
+
3.1.69
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.
|
1
|
+
3.1.69
|
data/lib/haml/precompiler.rb
CHANGED
@@ -534,8 +534,8 @@ END
|
|
534
534
|
result = attributes.collect do |attr, value|
|
535
535
|
next if value.nil?
|
536
536
|
|
537
|
-
value = filter_and_join(value, ' ') if attr ==
|
538
|
-
value = filter_and_join(value, '_') if attr ==
|
537
|
+
value = filter_and_join(value, ' ') if attr == 'class'
|
538
|
+
value = filter_and_join(value, '_') if attr == 'id'
|
539
539
|
|
540
540
|
if value == true
|
541
541
|
next " #{attr}" if is_html
|
@@ -561,8 +561,10 @@ END
|
|
561
561
|
end
|
562
562
|
|
563
563
|
def self.filter_and_join(value, separator)
|
564
|
+
return "" if value == ""
|
564
565
|
value = [value] unless value.is_a?(Array)
|
565
|
-
|
566
|
+
value = value.flatten.collect {|item| item ? item.to_s : nil}.compact.join(separator)
|
567
|
+
return !value.empty? && value
|
566
568
|
end
|
567
569
|
|
568
570
|
def prerender_tag(name, self_close, attributes)
|
data/test/haml/engine_test.rb
CHANGED
@@ -148,7 +148,7 @@ MESSAGE
|
|
148
148
|
assert_equal("<p class='b css'>foo</p>\n", render("%p.css{:class => %w[css b]} foo")) # merge uniquely
|
149
149
|
assert_equal("<p class='a b c d'>foo</p>\n", render("%p{:class => [%w[a b], %w[c d]]} foo")) # flatten
|
150
150
|
assert_equal("<p class='a b'>foo</p>\n", render("%p{:class => [:a, :b] } foo")) # stringify
|
151
|
-
assert_equal("<p
|
151
|
+
assert_equal("<p>foo</p>\n", render("%p{:class => [nil, false] } foo")) # strip falsey
|
152
152
|
assert_equal("<p class='a'>foo</p>\n", render("%p{:class => :a} foo")) # single stringify
|
153
153
|
assert_equal("<p>foo</p>\n", render("%p{:class => false} foo")) # single falsey
|
154
154
|
assert_equal("<p class='a b html'>foo</p>\n", render("%p(class='html'){:class => %w[a b]} foo")) # html attrs
|
@@ -159,7 +159,7 @@ MESSAGE
|
|
159
159
|
assert_equal("<p id='css_a_b'>foo</p>\n", render("%p#css{:id => %w[a b]} foo")) # merge with css
|
160
160
|
assert_equal("<p id='a_b_c_d'>foo</p>\n", render("%p{:id => [%w[a b], %w[c d]]} foo")) # flatten
|
161
161
|
assert_equal("<p id='a_b'>foo</p>\n", render("%p{:id => [:a, :b] } foo")) # stringify
|
162
|
-
assert_equal("<p
|
162
|
+
assert_equal("<p>foo</p>\n", render("%p{:id => [nil, false] } foo")) # strip falsey
|
163
163
|
assert_equal("<p id='a'>foo</p>\n", render("%p{:id => :a} foo")) # single stringify
|
164
164
|
assert_equal("<p>foo</p>\n", render("%p{:id => false} foo")) # single falsey
|
165
165
|
assert_equal("<p id='html_a_b'>foo</p>\n", render("%p(id='html'){:id => %w[a b]} foo")) # html attrs
|