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
11 changes: 8 additions & 3 deletions crates/ironhtml-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ struct ForLoop {

impl Parse for ForLoop {
fn parse(input: ParseStream) -> Result<Self> {
input.parse::<Token![for]>()?;
let for_token: Token![for] = input.parse()?;
let pat = syn::Pat::parse_single(input)?;
input.parse::<Token![in]>()?;
input.parse::<Token![#]>()?;
Expand All @@ -329,6 +329,13 @@ impl Parse for ForLoop {
children.push(content.parse()?);
}

if children.len() != 1 || !matches!(children.first(), Some(Node::Element(_))) {
return Err(syn::Error::new(
for_token.span,
"for loop body must contain exactly one element",
));
}

Ok(Self {
pat,
expr,
Expand Down Expand Up @@ -464,8 +471,6 @@ fn to_pascal_case(s: &str) -> String {
"Em" => "Em".to_string(),
"Rp" => "Rp".to_string(),
"Rt" => "Rt".to_string(),
"Rb" => "Rb".to_string(),
"Rtc" => "Rtc".to_string(),
"Wbr" => "Wbr".to_string(),
"Kbd" => "Kbd".to_string(),
"Pre" => "Pre".to_string(),
Expand Down
Loading