Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 86ea684

Browse files
committed
Revert "Assume that AttributeParser will always be available"
This reverts commit caf213b. We can continue using the existing method in haml 6.0.1 per haml/haml#1085.
1 parent caf213b commit 86ea684

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

lib/syntax_tree/haml/format.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,15 @@ def visit_tag(node)
330330
if node.value[:dynamic_attributes].old
331331
parts << PlainPart.new("%div") if parts.empty?
332332

333-
dynamic = parse_attributes(node.value[:dynamic_attributes].old)
334-
parts << if dynamic.is_a?(LiteralHashValue)
335-
PlainPart.new(dynamic.value)
333+
if ::Haml::AttributeParser.available?
334+
dynamic = parse_attributes(node.value[:dynamic_attributes].old)
335+
parts << if dynamic.is_a?(LiteralHashValue)
336+
PlainPart.new(dynamic.value)
337+
else
338+
HashAttributesPart.new(dynamic)
339+
end
336340
else
337-
HashAttributesPart.new(dynamic)
341+
parts << PlainPart.new(node.value[:dynamic_attributes].old)
338342
end
339343
end
340344

test/tag_test.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,17 @@ def test_long_declaration_before_text
121121
HAML
122122
end
123123

124+
def test_long_declaration_before_text_without_parser
125+
long = "a" * 80
126+
127+
::Haml::AttributeParser.stub(:available?, false) do
128+
assert_format("%button{ data: { current: #{long} } } foo", <<~HAML)
129+
%button{ data: { current: #{long} } }
130+
foo
131+
HAML
132+
end
133+
end
134+
124135
def test_quotes_in_strings
125136
assert_format("%div{title: 'escape \" quotes'}")
126137
end

0 commit comments

Comments
 (0)