Skip to content

Commit c9fb1aa

Browse files
committed
Cleaner tag pretty_print
1 parent c1264c9 commit c9fb1aa

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ From the CLI:
3636

3737
```sh
3838
$ stree ast template.haml
39-
(root children=[(tag attributes={} value="Hello, world!")])
39+
(root children=[(tag name="span" value="Hello, world!")])
4040
```
4141

4242
or

Diff for: lib/syntax_tree/haml/tag.rb

+8-2
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,14 @@ def format(q)
233233
def pretty_print(q)
234234
q.group(2, "(tag", ")") do
235235
q.breakable
236-
q.text("attributes=")
237-
q.pp(node.value[:attributes])
236+
q.text("name=")
237+
q.pp(node.value[:name])
238+
239+
if node.value[:attributes].any?
240+
q.breakable
241+
q.text("attributes=")
242+
q.pp(node.value[:attributes])
243+
end
238244

239245
if node.value[:dynamic_attributes].new
240246
q.breakable

0 commit comments

Comments
 (0)