diff --git a/lib/rufo/erb_formatter.rb b/lib/rufo/erb_formatter.rb index 49cd390d..3f146c45 100644 --- a/lib/rufo/erb_formatter.rb +++ b/lib/rufo/erb_formatter.rb @@ -8,7 +8,7 @@ def initialize(src) end def stags - ["<%==", "<%+={0,2}"] + super + ["<%-", "<%==", "<%+={0,2}"] + super end def etags diff --git a/spec/lib/rufo/erb_formatter_spec.rb b/spec/lib/rufo/erb_formatter_spec.rb index 9ad8816c..f00ed0ba 100644 --- a/spec/lib/rufo/erb_formatter_spec.rb +++ b/spec/lib/rufo/erb_formatter_spec.rb @@ -99,5 +99,25 @@ result = subject.format("<% # TODO: fix this later %>") expect(result).to eql("<% # TODO: fix this later %>") end + + it "handles leading whitespace trim tag" do + result = subject.format('<%- if controller_name != "sessions" %>') + expect(result).to eql('<%- if controller_name != "sessions" %>') + end + + it "handles trailing whitespace trim tag" do + result = subject.format('<% if controller_name != "sessions" -%>') + expect(result).to eql('<% if controller_name != "sessions" -%>') + end + + it "handles both whitespace trim tag" do + result = subject.format('<%- if controller_name != "sessions" -%>') + expect(result).to eql('<%- if controller_name != "sessions" -%>') + end + + it "handles minus unary operator" do + result = subject.format("<% - x * y %>") + expect(result).to eql("<% -x * y %>") + end end end