Skip to content

Commit

Permalink
feat: make the self close tag can be parse
Browse files Browse the repository at this point in the history
  • Loading branch information
meloalright committed Jan 27, 2024
1 parent fdd9a6e commit c02321e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion rustle/src/compiler/parse/fragments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@ fn parse_element(parser: &mut Parser) -> Option<RustleElement> {

let tag_name = parser.read_while_matching(&ELEMENT_TAG_NAME);
let attributes = parse_attribute_list(parser);

if parser.match_str("/>") {
parser.eat("/>");

let element = Some(RustleElement {
name: tag_name,
attributes: attributes,
fragments: vec![],
});
return element;
}

parser.eat(">");

let end_tag = format!("</{}>", tag_name);
Expand Down Expand Up @@ -151,7 +163,7 @@ fn parse_attribute_list(parser: &mut Parser) -> Vec<RustleAttribute> {
let mut attributes = Vec::new();
parser.skip_whitespace();

while !parser.match_str(">") {
while !parser.match_str(">") && !parser.match_str("/>") {
attributes.push(parse_attribute(parser));
parser.skip_whitespace();
}
Expand Down

0 comments on commit c02321e

Please sign in to comment.