Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to using refs instead of owned for autofmt write block out #2573

Merged
merged 1 commit into from
Jul 2, 2024
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
2 changes: 1 addition & 1 deletion packages/autofmt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pub fn fmt_file(contents: &str, indent: IndentOptions) -> Vec<FormattedBlock> {
formatted_blocks
}

pub fn write_block_out(body: CallBody) -> Option<String> {
pub fn write_block_out(body: &CallBody) -> Option<String> {
let mut buf = Writer::new("");

write_body(&mut buf, &body);
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/cli/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub fn convert_html_to_formatted_rsx(dom: &Dom, component: bool) -> String {

match component {
true => write_callbody_with_icon_section(callbody),
false => dioxus_autofmt::write_block_out(callbody).unwrap(),
false => dioxus_autofmt::write_block_out(&callbody).unwrap(),
}
}

Expand All @@ -61,7 +61,7 @@ fn write_callbody_with_icon_section(mut callbody: CallBody) -> String {

rsx_rosetta::collect_svgs(&mut callbody.roots, &mut svgs);

let mut out = write_component_body(dioxus_autofmt::write_block_out(callbody).unwrap());
let mut out = write_component_body(dioxus_autofmt::write_block_out(&callbody).unwrap());

if !svgs.is_empty() {
write_svg_section(&mut out, svgs);
Expand All @@ -81,7 +81,7 @@ fn write_svg_section(out: &mut String, svgs: Vec<BodyNode>) {
out.push_str("\n\nmod icons {");
out.push_str("\n use super::*;");
for (idx, icon) in svgs.into_iter().enumerate() {
let raw = dioxus_autofmt::write_block_out(CallBody { roots: vec![icon] }).unwrap();
let raw = dioxus_autofmt::write_block_out(&CallBody { roots: vec![icon] }).unwrap();
out.push_str("\n\n pub fn icon_");
out.push_str(&idx.to_string());
out.push_str("() -> Element {\n rsx! {");
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,5 @@ pub fn translate_rsx(contents: String, _component: bool) -> String {
let callbody = rsx_rosetta::rsx_from_html(&dom);

// Convert the HTML to RSX
dioxus_autofmt::write_block_out(callbody).unwrap()
dioxus_autofmt::write_block_out(&callbody).unwrap()
}
2 changes: 1 addition & 1 deletion packages/rsx-rosetta/examples/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn main() {

let body = rsx_rosetta::rsx_from_html(&dom);

let out = dioxus_autofmt::write_block_out(body).unwrap();
let out = dioxus_autofmt::write_block_out(&body).unwrap();

println!("{out}");
}
2 changes: 1 addition & 1 deletion packages/rsx-rosetta/tests/h-tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn h_tags_translate() {

let body = rsx_rosetta::rsx_from_html(&dom);

let out = dioxus_autofmt::write_block_out(body).unwrap();
let out = dioxus_autofmt::write_block_out(&body).unwrap();

let expected = r#"
div {
Expand Down
2 changes: 1 addition & 1 deletion packages/rsx-rosetta/tests/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn raw_attribute() {

let body = rsx_rosetta::rsx_from_html(&dom);

let out = dioxus_autofmt::write_block_out(body).unwrap();
let out = dioxus_autofmt::write_block_out(&body).unwrap();

let expected = r#"
div {
Expand Down
4 changes: 2 additions & 2 deletions packages/rsx-rosetta/tests/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fn simple_elements() {

let body = rsx_rosetta::rsx_from_html(&dom);

let out = dioxus_autofmt::write_block_out(body).unwrap();
let out = dioxus_autofmt::write_block_out(&body).unwrap();

let expected = r#"
div {
Expand Down Expand Up @@ -50,7 +50,7 @@ fn deeply_nested() {

let body = rsx_rosetta::rsx_from_html(&dom);

let out = dioxus_autofmt::write_block_out(body).unwrap();
let out = dioxus_autofmt::write_block_out(&body).unwrap();

let expected = r#"
div {
Expand Down
2 changes: 1 addition & 1 deletion packages/rsx-rosetta/tests/web-component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn web_components_translate() {

let body = rsx_rosetta::rsx_from_html(&dom);

let out = dioxus_autofmt::write_block_out(body).unwrap();
let out = dioxus_autofmt::write_block_out(&body).unwrap();

let expected = r#"
div {
Expand Down
Loading