Skip to content

Commit

Permalink
Update code to handle currently-broken test
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-janeapp committed Feb 6, 2024
1 parent c393cc6 commit c70c54b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/erb/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,17 @@ def format_attributes(tag_name, attrs, tag_closing)
attrs.scan(ATTR).flatten.each do |attr|
attr.strip!
name, value = attr.split('=', 2)
if UNQUOTED_ATTR =~ attr
attr_html << indented("#{name}=\"#{value}\"")
next
end

if value.nil?
attr_html << indented("#{name}")
next
end

if value[0] != '"' && value[0] != "'"
attr_html << indented("#{name}=\"#{value}\"")
next
end

value_parts = value[1...-1].strip.split(/\s+/)
value_parts.sort_by!(&@css_class_sorter) if name == 'class' && @css_class_sorter

Expand Down

0 comments on commit c70c54b

Please sign in to comment.