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
6
6
7
7
## [ Unreleased]
8
8
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
+
9
30
## [ 0.9.4] - 2023-07-01
10
31
11
32
- Inline even more empty HTML-tags
Original file line number Diff line number Diff line change 1
1
PATH
2
2
remote: .
3
3
specs:
4
- w_syntax_tree-erb (0.9.4 )
4
+ w_syntax_tree-erb (0.9.5 )
5
5
prettier_print (~> 1.2 , >= 1.2.0 )
6
6
syntax_tree (~> 6.1 , >= 6.1.1 )
7
7
Original file line number Diff line number Diff line change @@ -118,18 +118,19 @@ def visit_erb_content(node)
118
118
if node . value . is_a? ( String )
119
119
output_rows ( node . value . split ( "\n " ) )
120
120
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 ) }
122
123
123
- if child_nodes . size == 1
124
+ if nodes . size == 1
124
125
q . text ( " " )
125
- q . seplist ( child_nodes , -> { q . breakable ( "" ) } ) do |child_node |
126
+ q . seplist ( nodes , -> { q . breakable ( "" ) } ) do |child_node |
126
127
format_statement ( child_node )
127
128
end
128
129
q . text ( " " )
129
- elsif child_nodes . size > 1
130
+ elsif nodes . size > 1
130
131
q . indent do
131
132
q . breakable ( "" )
132
- q . seplist ( child_nodes , -> { q . breakable ( "" ) } ) do |child_node |
133
+ q . seplist ( nodes , -> { q . breakable ( "" ) } ) do |child_node |
133
134
format_statement ( child_node )
134
135
end
135
136
end
Original file line number Diff line number Diff line change 2
2
3
3
module SyntaxTree
4
4
module ERB
5
- VERSION = "0.9.4 "
5
+ VERSION = "0.9.5 "
6
6
end
7
7
end
Original file line number Diff line number Diff line change @@ -62,6 +62,15 @@ def test_erb_with_comment
62
62
assert_equal ( source , formatted_twice )
63
63
end
64
64
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
+
65
74
def test_erb_ternary_as_argument_without_parentheses
66
75
source =
67
76
"<%= f.submit f.object.id.present? ? t('buttons.titles.save'):t('buttons.titles.create') %>"
Original file line number Diff line number Diff line change 2
2
<%# This is an ERB-comment https://stackoverflow.com/a/25626629 this answer describes ERB and erubis syntax%>
3
3
<%== rails_raw_output %>
4
4
<%- "this only works in ERB not erubis" %>
5
+ <% # This should be written on one line %>
5
6
6
7
<% if this -%>
7
8
<%= form.submit -%>
Original file line number Diff line number Diff line change 2
2
<%# This is an ERB-comment https://stackoverflow.com/a/25626629 this answer describes ERB and erubis syntax%>
3
3
<%== rails_raw_output%>
4
4
<%- "this only works in ERB not erubis"%>
5
+ <% # This should be written on one line %>
5
6
6
7
<% if this -%>
7
8
<%= form.submit -%>
You can’t perform that action at this time.
0 commit comments