Skip to content

Commit

Permalink
fix: correctly handle empty view! {} in hot-reloading code (closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
gbj authored Apr 1, 2024
1 parent 41f3c46 commit b79037b
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions leptos_hot_reload/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,20 @@ impl ViewMacros {
for view in visitor.views {
let span = view.span();
let id = span_to_stable_id(path, span.start().line);
let tokens = view.tokens.clone().into_iter();
// TODO handle class = ...
let rsx =
rstml::parse2(tokens.collect::<proc_macro2::TokenStream>())?;
let template = LNode::parse_view(rsx)?;
views.push(MacroInvocation { id, template });
if view.tokens.is_empty() {
views.push(MacroInvocation {
id,
template: LNode::Fragment(Vec::new()),
});
} else {
let tokens = view.tokens.clone().into_iter();
// TODO handle class = ...
let rsx = rstml::parse2(
tokens.collect::<proc_macro2::TokenStream>(),
)?;
let template = LNode::parse_view(rsx)?;
views.push(MacroInvocation { id, template });
}
}
Ok(views)
}
Expand Down

0 comments on commit b79037b

Please sign in to comment.