erb-formatter 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba78d2f06a198fd4f9af049e11a4f0ec92fcfa56e16688eaa65b3ea9253320ca
4
- data.tar.gz: 5d06c40737f856c445cf70fd530639e8876c60dad08d9fdc91acc12e42c9e086
3
+ metadata.gz: be0f34943fd5862e17b5092eb8a8122534727b4a03df5fe1dde6cd6a4f480724
4
+ data.tar.gz: 5dc8b6d8e15485859fca2cb4d6714d1058b7621034d60301e135d764283e4d0c
5
5
  SHA512:
6
- metadata.gz: 4997b2e942b1fe2ed3a0bf0b0e828ba7565090bf781508accd4d64540e90b986d7d0414534e066cd149d56d8d208342dd20c6ac1ba749498e03b080d4e799a10
7
- data.tar.gz: 59901e642196b0538e88379384d655a8f6a174007ba30fa7829b25db829cedbc8bcb94ef80e58b026e6223cc166fa442db798c84a18d38baecf5c36d63cee3cf
6
+ metadata.gz: 625dfa362a1521ed5da14bb0b03b952744d37bccf2881b55aec2cf78b72ac7373d4bad5f2b6d672d68e97031abdd63dd823c7280e8a70aa70e8686641d1bc0b7
7
+ data.tar.gz: 1f3a8954dd02dd6a36fe0765cf08ccfd595b4a2b19dbaaf449077f4846bdaaae0faa220f25c6f351612ae58b06b61e4f3680a644fb37212107ac382299331990
@@ -3,5 +3,5 @@
3
3
  require 'erb'
4
4
 
5
5
  class ERB::Formatter
6
- VERSION = "0.5.0"
6
+ VERSION = "0.6.0"
7
7
  end
data/lib/erb/formatter.rb CHANGED
@@ -9,6 +9,7 @@ require 'securerandom'
9
9
  require 'erb/formatter/version'
10
10
 
11
11
  require 'syntax_tree'
12
+ require 'syntax_tree/plugin/trailing_comma'
12
13
 
13
14
  class ERB::Formatter
14
15
  module SyntaxTreeCommandPatch
@@ -124,15 +125,21 @@ class ERB::Formatter
124
125
 
125
126
  attrs.scan(ATTR).flatten.each do |attr|
126
127
  attr.strip!
127
- full_attr = indented(attr)
128
128
  name, value = attr.split('=', 2)
129
129
 
130
+ if value.nil?
131
+ attr_html << indented("#{name}")
132
+ next
133
+ end
134
+
135
+ value_parts = value[1...-1].strip.split(/\s+/)
136
+
137
+ full_attr = indented("#{name}=#{value[0]}#{value_parts.join(" ")}#{value[-1]}")
138
+
130
139
  if full_attr.size > line_width && MULTILINE_ATTR_NAMES.include?(name) && attr.match?(QUOTED_ATTR)
131
140
  attr_html << indented("#{name}=#{value[0]}")
132
141
  tag_stack_push('attr"', value)
133
142
 
134
- value_parts = value[1...-1].strip.split(/\s+/)
135
-
136
143
  if !@single_class_per_line && name == 'class'
137
144
  line = value_parts.shift
138
145
  value_parts.each do |value_part|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erb-formatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elia Schito