Skip to content

Commit bad2142

Browse files
authored
Handle do-arguments in ERB-tags and release 0.10.5 (#67)
* Handles spaces after do-arguments in ERB-tags * Release 0.10.5
1 parent c2f2a05 commit bad2142

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
66

77
## [Unreleased]
88

9+
## [0.10.5] - 2023-09-03
10+
911
- Handle ERB-tags inside HTML-tags, like `<div <%= "class='foo'" %>>`
1012
- Handles indentation for multiline ERB-comment
13+
- Handles spaces between do-arguments and ERB-tags
1114

1215
## [0.10.4] - 2023-08-28
1316

@@ -106,7 +109,8 @@ Output:
106109
- Can format a lot of .html.erb-syntax and works as a plugin to syntax_tree.
107110
- This is still early and there are a lot of different weird syntaxes out there.
108111

109-
[unreleased]: https://github.com/davidwessman/syntax_tree-erb/compare/v0.10.4...HEAD
112+
[unreleased]: https://github.com/davidwessman/syntax_tree-erb/compare/v0.10.5...HEAD
113+
[0.10.5]: https://github.com/davidwessman/syntax_tree-erb/compare/v0.10.4...v0.10.5
110114
[0.10.4]: https://github.com/davidwessman/syntax_tree-erb/compare/v0.10.3...v0.10.4
111115
[0.10.3]: https://github.com/davidwessman/syntax_tree-erb/compare/v0.10.2...v0.10.3
112116
[0.10.2]: https://github.com/davidwessman/syntax_tree-erb/compare/v0.10.1...v0.10.2

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
w_syntax_tree-erb (0.10.4)
4+
w_syntax_tree-erb (0.10.5)
55
prettier_print (~> 1.2, >= 1.2.0)
66
syntax_tree (~> 6.1, >= 6.1.1)
77

lib/syntax_tree/erb/format.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ def visit_erb(node)
121121
end
122122

123123
def visit_erb_do_close(node)
124-
visit(node.closing)
124+
closing = node.closing.value.end_with?("-%>") ? "-%>" : "%>"
125+
q.text(node.closing.value.gsub(closing, "").rstrip)
126+
q.text(" ")
127+
q.text(closing)
125128
end
126129

127130
def visit_erb_close(node)

lib/syntax_tree/erb/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
module SyntaxTree
44
module ERB
5-
VERSION = "0.10.4"
5+
VERSION = "0.10.5"
66
end
77
end

test/erb_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ def test_erb_whitespace
139139
assert_formatting(source, expected)
140140
end
141141

142+
def test_erb_block_do_arguments
143+
source = "<%= link_to(url) do |link, other_arg|%>Whaaaaaaat<% end %>"
144+
expected =
145+
"<%= link_to(url) do |link, other_arg| %>\n Whaaaaaaat\n<% end %>\n"
146+
147+
assert_formatting(source, expected)
148+
end
149+
142150
def test_erb_newline
143151
source = "<%= what if this %>\n<h1>hej</h1>"
144152
expected = "<%= what if this %>\n<h1>hej</h1>\n"

0 commit comments

Comments
 (0)