diff --git a/src/transpiling/jsx_string.rs b/src/transpiling/jsx_string.rs index 037b942..8a27623 100644 --- a/src/transpiling/jsx_string.rs +++ b/src/transpiling/jsx_string.rs @@ -18,7 +18,7 @@ use swc_ecma_visit::{ struct JsxString { next_index: usize, - templates: Vec<(usize, (Vec, Vec))>, + templates: Vec<(usize, Vec)>, } impl Default for JsxString { @@ -36,17 +36,14 @@ fn create_tpl_binding_name(index: usize) -> String { fn serialize_jsx_element_to_string_vec( el: JSXElement, -) -> (Vec, Vec) { +) -> (Vec, Vec>) { let name = match el.opening.name { JSXElementName::Ident(ident) => ident.sym.to_string(), _ => todo!(), }; - - let mut strings: Vec = vec![ - String::from("<") - ]; - let mut dynamic_exprs: Vec = vec![]; + let mut strings: Vec = vec![String::from("<")]; + let mut dynamic_exprs: Vec> = vec![]; strings.last_mut().unwrap().push_str(name.as_str()); @@ -54,12 +51,14 @@ fn serialize_jsx_element_to_string_vec( for attr in el.opening.attrs.iter() { let mut is_dynamic = false; let mut serialized_attr = String::new(); + let mut name = "".to_string(); // ; "#, - r#"const $$_tpl_1 = ["
Hello!
"]; -const $$_tpl_2 = ["
Hello", "!
"]; -const $$_tpl_3 = ["]; -const a = $$_tpl_1.join(""); + r#"const $$_tpl_1 = [ + "
Hello!
" +]; +const $$_tpl_2 = [ + "
Hello ", + "!
" +]; +const $$_tpl_3 = [ + '" +]; +const a = renderFunction($$_tpl_1, null); const b = renderFunction($$_tpl_2, name); -const c = renderFunction($$_tpl_3, { onClick }, name);"#, +const c = renderFunction($$_tpl_3, { + "onClick": onClick +}, name);"#, ); }