Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion crates/biome_html_formatter/src/html/lists/attribute_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ pub(crate) struct FormatHtmlAttributeList;
impl FormatRule<HtmlAttributeList> for FormatHtmlAttributeList {
type Context = HtmlFormatContext;
fn fmt(&self, node: &HtmlAttributeList, f: &mut HtmlFormatter) -> FormatResult<()> {
let line_break = if f.options().attribute_position() == AttributePosition::Multiline {
let attribute_len = node.iter().len();
let line_break = if f.options().attribute_position() == AttributePosition::Multiline
&& attribute_len > 1
{
hard_line_break()
} else {
soft_line_break_or_space()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div foo="bar" disabled bar="foo"></div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
source: crates/biome_formatter_test/src/snapshot_builder.rs
assertion_line: 211
info: attributes/multiline/break.html
---
# Input

```html
<div foo="bar" disabled bar="foo"></div>

```


=============================

# Outputs

## Output 1

-----
Indent style: Tab
Indent width: 2
Line ending: LF
Line width: 80
Attribute Position: Auto
Bracket same line: false
Whitespace sensitivity: strict
Indent script and style: false
-----

```html
<div foo="bar" disabled bar="foo"></div>
```

## Output 1

-----
Indent style: Tab
Indent width: 2
Line ending: LF
Line width: 80
Attribute Position: Multiline
Bracket same line: false
Whitespace sensitivity: strict
Indent script and style: false
-----

```html
<div
foo="bar"
disabled
bar="foo"
></div>
```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div foo="bar"></div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
source: crates/biome_formatter_test/src/snapshot_builder.rs
assertion_line: 211
info: attributes/multiline/no-break.html
---
# Input

```html
<div foo="bar"></div>

```


=============================

# Outputs

## Output 1

-----
Indent style: Tab
Indent width: 2
Line ending: LF
Line width: 80
Attribute Position: Auto
Bracket same line: false
Whitespace sensitivity: strict
Indent script and style: false
-----

```html
<div foo="bar"></div>
```

## Output 1

-----
Indent style: Tab
Indent width: 2
Line ending: LF
Line width: 80
Attribute Position: Multiline
Bracket same line: false
Whitespace sensitivity: strict
Indent script and style: false
-----

```html
<div foo="bar"></div>
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "../../../../../../../packages/@biomejs/biome/configuration_schema.json",
"formatter": {
"attributePosition": "multiline"
}
}
1 change: 1 addition & 0 deletions crates/biome_service/src/file_handlers/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ impl From<HtmlFormatterConfiguration> for HtmlFormatterSettings {
line_width: config.line_width,
indent_width: config.indent_width,
indent_style: config.indent_style,
attribute_position: config.attribute_position,
..Default::default()
}
}
Expand Down
Loading