Skip to content

Commit bf18cbe

Browse files
authored
0.9.4: Format empty HTML-tags as a group (#43)
```diff <three-word-component :attribute1 :attribute2 :attribute3="value" -> -</three-word-component> +></three-word-component> ```
1 parent 98227e3 commit bf18cbe

File tree

6 files changed

+29
-5
lines changed

6 files changed

+29
-5
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
66

77
## [Unreleased]
88

9+
## [0.9.4] - 2023-07-01
10+
11+
- Inline even more empty HTML-tags
12+
13+
```diff
14+
<three-word-component
15+
:attribute1
16+
:attribute2
17+
:attribute3="value"
18+
->
19+
-</three-word-component>
20+
+></three-word-component>
21+
```
22+
923
## [0.9.3] - 2023-06-30
1024

1125
- Print empty html-tags on one line if possible

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.9.3)
4+
w_syntax_tree-erb (0.9.4)
55
prettier_print (>= 1.2.0)
66
syntax_tree (>= 6.1.1)
77

lib/syntax_tree/erb/format.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ def visit_block(node)
5151
def visit_html(node)
5252
# Make sure to group the tags together if there is no child nodes.
5353
if node.elements.size == 0
54-
q.group { visit_block(node) }
54+
q.group do
55+
visit(node.opening)
56+
visit(node.closing)
57+
end
5558
else
5659
visit_block(node)
5760
end

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.9.3"
5+
VERSION = "0.9.4"
66
end
77
end

test/fixture/javascript_frameworks_formatted.html.erb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
boolean
77
:value="['a', 'b']"
88
:long-variable-name="data.item.javascript.code"
9-
>
10-
</card-header>
9+
></card-header>
1110

1211
<card-body :content="<%= @content %>" @click="doThis">
1312
<template #button-content>
@@ -16,6 +15,11 @@
1615
</card-body>
1716
</div>
1817

18+
<three-word-component
19+
:allowed-words="['first', 'second', 'third', 'fourth']"
20+
:disallowed-words="['fifth', 'sixth']"
21+
></three-word-component>
22+
1923
<!-- Alpine -->
2024
<div
2125
x-data="{open: false}"

test/fixture/javascript_frameworks_unformatted.html.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33

44
<card-body :content="<%= @content %>" @click="doThis"><template #button-content>Hello</template></card-body></div>
55

6+
<three-word-component :allowed-words="['first', 'second', 'third', 'fourth']" :disallowed-words="['fifth', 'sixth']">
7+
</three-word-component>
8+
69
<!-- Alpine --><div x-data="{open: false}" class="absolute bottom-0" x-transition:enter="transition ease-out" x-transition:leave="transition ease-in">
710
<button @click="open = true">Expand</button><span x-show="open"><h1>Hello</h1></span></div>

0 commit comments

Comments
 (0)