diff --git a/lib/erb/formatter.rb b/lib/erb/formatter.rb index 3e1db4f..0455407 100644 --- a/lib/erb/formatter.rb +++ b/lib/erb/formatter.rb @@ -141,12 +141,12 @@ def format_attributes(tag_name, attrs, tag_closing) name, value = attr.split('=', 2) if value.nil? - attr_html << indented("#{name}") + attr_html << (within_line_width ? " #{name}" : indented("#{name}")) next end if /\A#{UNQUOTED_VALUE}\z/o.match?(value) - attr_html << indented("#{name}=\"#{value}\"") + attr_html << (within_line_width ? " #{name}=\"#{value}\"" : indented("#{name}=\"#{value}\"")) next end diff --git a/test/fixtures/attributes.html.erb b/test/fixtures/attributes.html.erb index daaeb6d..e87be9a 100644 --- a/test/fixtures/attributes.html.erb +++ b/test/fixtures/attributes.html.erb @@ -9,3 +9,5 @@ data-short-url="//test.com/?q=v" data-long-url="https://google.ca/this-is-a-long-url-with-a-query-string?query=something" data-long-url-single='https://google.ca/this-is-a-long-url-with-a-query-string?query=something'> + + diff --git a/test/fixtures/attributes.html.expected.erb b/test/fixtures/attributes.html.expected.erb index 0aed143..2419918 100644 --- a/test/fixtures/attributes.html.expected.erb +++ b/test/fixtures/attributes.html.expected.erb @@ -8,3 +8,10 @@ data-long-url="https://google.ca/this-is-a-long-url-with-a-query-string?query=something" data-long-url-single='https://google.ca/this-is-a-long-url-with-a-query-string?query=something' > + +