erb-formatter 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/erb/formatter/version.rb +1 -1
- data/lib/erb/formatter.rb +10 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be0f34943fd5862e17b5092eb8a8122534727b4a03df5fe1dde6cd6a4f480724
|
4
|
+
data.tar.gz: 5dc8b6d8e15485859fca2cb4d6714d1058b7621034d60301e135d764283e4d0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 625dfa362a1521ed5da14bb0b03b952744d37bccf2881b55aec2cf78b72ac7373d4bad5f2b6d672d68e97031abdd63dd823c7280e8a70aa70e8686641d1bc0b7
|
7
|
+
data.tar.gz: 1f3a8954dd02dd6a36fe0765cf08ccfd595b4a2b19dbaaf449077f4846bdaaae0faa220f25c6f351612ae58b06b61e4f3680a644fb37212107ac382299331990
|
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|
|