Skip to content

Commit

Permalink
fix: use view! indentation settings when formatting syn expressions (…
Browse files Browse the repository at this point in the history
…rust code

embedded in the view! macro)
  • Loading branch information
bram209 committed Aug 30, 2024
1 parent f40de7d commit fe1d82d
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 45 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion formatter/src/formatter/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,14 @@ mod tests {

#[test]
fn key_value_expr_attr_always_unless_lit_braces() {
// sinle expr without braces
// single expr without braces
let f = format_attr_with_brace_style! { AlwaysUnlessLit => on:click=move |_| set_value(0) };
assert_snapshot!(f, @"on:click={move |_| set_value(0)}");

// single expr without braces
let f = format_attr_with_brace_style! { AlwaysUnlessLit => foo=bar };
assert_snapshot!(f, @"foo={bar}");

// single expr with braces
let f =
format_attr_with_brace_style! { AlwaysUnlessLit => on:click={move |_| set_value(0)} };
Expand Down
4 changes: 2 additions & 2 deletions formatter/src/formatter/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ mod tests {
let formatted = format_element_from_string!(indoc! {"
<div key=a
// width
width=100></div>
width=100></div>
"});

insta::assert_snapshot!(formatted, @r###"
Expand Down Expand Up @@ -361,7 +361,7 @@ mod tests {
let formatted = format_element_from_string!(indoc! {"
<div>
Unquoted text
with spaces
with spaces
</div>
"});

Expand Down
6 changes: 2 additions & 4 deletions formatter/src/formatter/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,10 @@ impl Formatter<'_> {

#[cfg(test)]
mod tests {
use rstml::node::Node;


use crate::formatter::*;
use crate::test_helpers::{
element, element_from_string, format_element_from_string, format_with,
};
use crate::test_helpers::format_element_from_string;

macro_rules! format_element {

Check warning on line 161 in formatter/src/formatter/expr.rs

View workflow job for this annotation

GitHub Actions / Test Suite

unused macro definition: `format_element`
($($tt:tt)*) => {{
Expand Down
Loading

0 comments on commit fe1d82d

Please sign in to comment.