소스 검색

allow the last attribute in a component to contain formatting (#504)

Demonthos 2 년 전
부모
커밋
4a8a7dd5f4
1개의 변경된 파일9개의 추가작업 그리고 7개의 파일을 삭제
  1. 9 7
      packages/rsx/src/component.rs

+ 9 - 7
packages/rsx/src/component.rs

@@ -234,13 +234,15 @@ impl Parse for ComponentField {
             let content = ContentField::ManExpr(input.parse()?);
             return Ok(Self { name, content });
         }
-
-        if input.peek(LitStr) && input.peek2(Token![,]) {
-            let t: LitStr = input.fork().parse()?;
-
-            if is_literal_foramtted(&t) {
-                let content = ContentField::Formatted(input.parse()?);
-                return Ok(Self { name, content });
+        if input.peek(LitStr) {
+            let forked = input.fork();
+            let t: LitStr = forked.parse()?;
+            // the string literal must either be the end of the input or a followed by a comma
+            if forked.is_empty() || forked.peek(Token![,]) {
+                if is_literal_foramtted(&t) {
+                    let content = ContentField::Formatted(input.parse()?);
+                    return Ok(Self { name, content });
+                }
             }
         }