File tree Expand file tree Collapse file tree 7 files changed +40
-7
lines changed Expand file tree Collapse file tree 7 files changed +40
-7
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,27 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
66
77## [ Unreleased]
88
9+ ## [ 0.9.5] - 2023-07-02
10+
11+ - Fixes ruby comment in ERB-tag included VoidStatement
12+ Example:
13+
14+ ``` erb
15+ <% # this is a comment %>
16+ ```
17+
18+ Output:
19+
20+ ``` diff
21+ - <%
22+ -
23+ - # this is a comment
24+ - %>
25+ + <% # this is a comment %>
26+ ```
27+
28+ - Updates versions in Bundler
29+
930## [ 0.9.4] - 2023-07-01
1031
1132- Inline even more empty HTML-tags
Original file line number Diff line number Diff line change 11PATH
22 remote: .
33 specs:
4- w_syntax_tree-erb (0.9.4 )
4+ w_syntax_tree-erb (0.9.5 )
55 prettier_print (~> 1.2 , >= 1.2.0 )
66 syntax_tree (~> 6.1 , >= 6.1.1 )
77
Original file line number Diff line number Diff line change @@ -118,18 +118,19 @@ def visit_erb_content(node)
118118 if node . value . is_a? ( String )
119119 output_rows ( node . value . split ( "\n " ) )
120120 else
121- child_nodes = node . value &.statements &.child_nodes || [ ]
121+ nodes = node . value &.statements &.child_nodes || [ ]
122+ nodes = nodes . reject { |node | node . is_a? ( SyntaxTree ::VoidStmt ) }
122123
123- if child_nodes . size == 1
124+ if nodes . size == 1
124125 q . text ( " " )
125- q . seplist ( child_nodes , -> { q . breakable ( "" ) } ) do |child_node |
126+ q . seplist ( nodes , -> { q . breakable ( "" ) } ) do |child_node |
126127 format_statement ( child_node )
127128 end
128129 q . text ( " " )
129- elsif child_nodes . size > 1
130+ elsif nodes . size > 1
130131 q . indent do
131132 q . breakable ( "" )
132- q . seplist ( child_nodes , -> { q . breakable ( "" ) } ) do |child_node |
133+ q . seplist ( nodes , -> { q . breakable ( "" ) } ) do |child_node |
133134 format_statement ( child_node )
134135 end
135136 end
Original file line number Diff line number Diff line change 22
33module SyntaxTree
44 module ERB
5- VERSION = "0.9.4 "
5+ VERSION = "0.9.5 "
66 end
77end
Original file line number Diff line number Diff line change @@ -62,6 +62,15 @@ def test_erb_with_comment
6262 assert_equal ( source , formatted_twice )
6363 end
6464
65+ def test_erb_only_comment
66+ source = "<% # This should be written on one line %>\n "
67+ formatted_once = ERB . format ( source )
68+ formatted_twice = ERB . format ( formatted_once )
69+
70+ assert_equal ( source , formatted_once )
71+ assert_equal ( source , formatted_twice )
72+ end
73+
6574 def test_erb_ternary_as_argument_without_parentheses
6675 source =
6776 "<%= f.submit f.object.id.present? ? t('buttons.titles.save'):t('buttons.titles.create') %>"
Original file line number Diff line number Diff line change 22<%# This is an ERB-comment https://stackoverflow.com/a/25626629 this answer describes ERB and erubis syntax%>
33<%== rails_raw_output %>
44<%- "this only works in ERB not erubis" %>
5+ <% # This should be written on one line %>
56
67<% if this -%>
78 <%= form.submit -%>
Original file line number Diff line number Diff line change 22<%# This is an ERB-comment https://stackoverflow.com/a/25626629 this answer describes ERB and erubis syntax%>
33<%== rails_raw_output%>
44<%- "this only works in ERB not erubis"%>
5+ <% # This should be written on one line %>
56
67<% if this -%>
78 <%= form.submit -%>
You can’t perform that action at this time.
0 commit comments