diff --git a/lib/erb/formatter.rb b/lib/erb/formatter.rb
index 9d766cc..dbc6f8a 100644
--- a/lib/erb/formatter.rb
+++ b/lib/erb/formatter.rb
@@ -124,15 +124,21 @@ def format_attributes(tag_name, attrs, tag_closing)
attrs.scan(ATTR).flatten.each do |attr|
attr.strip!
- full_attr = indented(attr)
name, value = attr.split('=', 2)
+ if value.nil?
+ attr_html << indented("#{name}")
+ next
+ end
+
+ value_parts = value[1...-1].strip.split(/\s+/)
+
+ full_attr = indented("#{name}=#{value[0]}#{value_parts.join(" ")}#{value[-1]}")
+
if full_attr.size > line_width && MULTILINE_ATTR_NAMES.include?(name) && attr.match?(QUOTED_ATTR)
attr_html << indented("#{name}=#{value[0]}")
tag_stack_push('attr"', value)
- value_parts = value[1...-1].strip.split(/\s+/)
-
if !@single_class_per_line && name == 'class'
line = value_parts.shift
value_parts.each do |value_part|
diff --git a/test/fixtures/multiline_attributes.html.erb b/test/fixtures/multiline_attributes.html.erb
index 2056283..d45f30b 100644
--- a/test/fixtures/multiline_attributes.html.erb
+++ b/test/fixtures/multiline_attributes.html.erb
@@ -1,3 +1,6 @@
+
+
diff --git a/test/fixtures/multiline_attributes.html.expected.erb b/test/fixtures/multiline_attributes.html.expected.erb
index 594fc8f..8d28ef1 100644
--- a/test/fixtures/multiline_attributes.html.expected.erb
+++ b/test/fixtures/multiline_attributes.html.expected.erb
@@ -7,3 +7,11 @@
aria-disabled:border-gray-300 aria-disabled:cursor-not-allowed
"
>Button
+
+