Skip to content

Commit 16c80fd

Browse files
authored
Merge pull request #353 from ruby-formatter/fix-335
Fix 335
2 parents a90e654 + fd0fd15 commit 16c80fd

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

lib/rufo/erb_formatter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def initialize(src)
88
end
99

1010
def stags
11-
["<%==", "<%+={0,2}"] + super
11+
["<%-", "<%==", "<%+={0,2}"] + super
1212
end
1313

1414
def etags

spec/lib/rufo/erb_formatter_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,25 @@
9999
result = subject.format("<% # TODO: fix this later %>")
100100
expect(result).to eql("<% # TODO: fix this later %>")
101101
end
102+
103+
it "handles leading whitespace trim tag" do
104+
result = subject.format('<%- if controller_name != "sessions" %>')
105+
expect(result).to eql('<%- if controller_name != "sessions" %>')
106+
end
107+
108+
it "handles trailing whitespace trim tag" do
109+
result = subject.format('<% if controller_name != "sessions" -%>')
110+
expect(result).to eql('<% if controller_name != "sessions" -%>')
111+
end
112+
113+
it "handles both whitespace trim tag" do
114+
result = subject.format('<%- if controller_name != "sessions" -%>')
115+
expect(result).to eql('<%- if controller_name != "sessions" -%>')
116+
end
117+
118+
it "handles minus unary operator" do
119+
result = subject.format("<% - x * y %>")
120+
expect(result).to eql("<% -x * y %>")
121+
end
102122
end
103123
end

0 commit comments

Comments
 (0)