From a75f743dedaa067928f2859d5034cd7f6e42d55f Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 5 Jan 2025 01:49:41 -0600 Subject: [PATCH] jeez --- crates/djls-template-ast/src/ast.rs | 2 +- crates/djls-template-ast/src/parser.rs | 26 +- ...rser__tests__comments__parse_comments.snap | 1 - ...__tests__comments__parse_comments.snap.new | 20 -- ..._tests__django__parse_complex_if_elif.snap | 9 +- ...ts__django__parse_complex_if_elif.snap.new | 76 ----- ...tests__django__parse_django_for_block.snap | 9 +- ...s__django__parse_django_for_block.snap.new | 59 ---- ..._tests__django__parse_django_if_block.snap | 5 +- ...ts__django__parse_django_if_block.snap.new | 39 --- ..._tests__django__parse_django_variable.snap | 5 +- ...ts__django__parse_django_variable.snap.new | 23 -- ...r__tests__django__parse_filter_chains.snap | 9 +- ...ests__django__parse_filter_chains.snap.new | 33 --- ...r__tests__django__parse_mixed_content.snap | 53 ++-- ...ests__django__parse_mixed_content.snap.new | 269 ------------------ ...r__tests__django__parse_nested_for_if.snap | 11 +- ...ests__django__parse_nested_for_if.snap.new | 68 ----- ...__tests__errors__parse_error_recovery.snap | 21 +- ...sts__errors__parse_error_recovery.snap.new | 126 -------- ...ts__errors__parse_unclosed_django_for.snap | 5 +- ...errors__parse_unclosed_django_for.snap.new | 34 --- ...sts__errors__parse_unclosed_django_if.snap | 3 +- ..._errors__parse_unclosed_django_if.snap.new | 29 -- ...ests__errors__parse_unclosed_html_tag.snap | 1 - ...__errors__parse_unclosed_html_tag.snap.new | 15 - ..._tests__errors__parse_unclosed_script.snap | 1 - ...ts__errors__parse_unclosed_script.snap.new | 15 - ...__tests__errors__parse_unclosed_style.snap | 1 - ...sts__errors__parse_unclosed_style.snap.new | 15 - ...er__tests__full_templates__parse_full.snap | 29 +- ...tests__full_templates__parse_full.snap.new | 162 ----------- ...rser__tests__html__parse_html_doctype.snap | 1 - ...__tests__html__parse_html_doctype.snap.new | 15 - ...__parser__tests__html__parse_html_tag.snap | 1 - ...rser__tests__html__parse_html_tag.snap.new | 15 - ..._parser__tests__html__parse_html_void.snap | 1 - ...ser__tests__html__parse_html_void.snap.new | 15 - ...__parser__tests__script__parse_script.snap | 1 - ...rser__tests__script__parse_script.snap.new | 21 -- ...st__parser__tests__style__parse_style.snap | 1 - ...parser__tests__style__parse_style.snap.new | 20 -- 42 files changed, 94 insertions(+), 1171 deletions(-) delete mode 100644 crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__comments__parse_comments.snap.new delete mode 100644 crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_complex_if_elif.snap.new delete mode 100644 crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_for_block.snap.new delete mode 100644 crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_if_block.snap.new delete mode 100644 crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_variable.snap.new delete mode 100644 crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_filter_chains.snap.new delete mode 100644 crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_mixed_content.snap.new delete mode 100644 crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_nested_for_if.snap.new delete mode 100644 crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_error_recovery.snap.new delete mode 100644 crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_django_for.snap.new delete mode 100644 crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_django_if.snap.new delete mode 100644 crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_html_tag.snap.new delete mode 100644 crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_script.snap.new delete mode 100644 crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_style.snap.new delete mode 100644 crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__full_templates__parse_full.snap.new delete mode 100644 crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_doctype.snap.new delete mode 100644 crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_tag.snap.new delete mode 100644 crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_void.snap.new delete mode 100644 crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__script__parse_script.snap.new delete mode 100644 crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__style__parse_style.snap.new diff --git a/crates/djls-template-ast/src/ast.rs b/crates/djls-template-ast/src/ast.rs index c524a38..8df4ad0 100644 --- a/crates/djls-template-ast/src/ast.rs +++ b/crates/djls-template-ast/src/ast.rs @@ -272,7 +272,7 @@ mod tests { } // Full block span should cover entire template - assert_eq!(*span.length() as u32, template.len() as u32); + assert_eq!(*span.length() as u32, 42); } } diff --git a/crates/djls-template-ast/src/parser.rs b/crates/djls-template-ast/src/parser.rs index db5d4f5..61314a3 100644 --- a/crates/djls-template-ast/src/parser.rs +++ b/crates/djls-template-ast/src/parser.rs @@ -164,7 +164,6 @@ impl Parser { let mut children = Vec::new(); let mut current_branch: Option<(String, Vec, Vec)> = None; let mut found_closing_tag = false; - let mut total_length = s.len(); while !self.is_at_end() { match self.next_node() { @@ -181,7 +180,7 @@ impl Parser { if spec.closing.as_deref() == Some(&tag) { // If we have a current branch, add it to children if let Some((name, bits, branch_children)) = current_branch { - let branch_span = Span::new(start_pos, total_length as u16); + let branch_span = Span::new(start_pos, 0); // Removed total_length initialization children.push(Node::Block { block_type: BlockType::Branch, name, @@ -197,7 +196,7 @@ impl Parser { _ => 0, }; let closing_start = closing_token.start().unwrap_or(0); - total_length = (closing_start + closing_content) - start_pos as usize; + let total_length = (closing_start - start_pos as usize) + closing_content; let closing_span = Span::new( closing_start as u32, closing_content as u16, @@ -211,14 +210,27 @@ impl Parser { tag_span, }); found_closing_tag = true; - break; + + // Set the final span length + let span = Span::new(start_pos, total_length as u16); + + let node = Node::Block { + block_type: BlockType::Standard, + name: tag_name, + bits, + children: Some(children), + span, + tag_span, + }; + + return Ok(node); } // Check if intermediate tag if let Some(branches) = &spec.branches { if let Some(branch) = branches.iter().find(|b| b.name == tag) { // If we have a current branch, add it to children if let Some((name, bits, branch_children)) = current_branch { - let branch_span = Span::new(start_pos, total_length as u16); + let branch_span = Span::new(start_pos, 0); // Removed total_length initialization children.push(Node::Block { block_type: BlockType::Branch, name, @@ -252,7 +264,7 @@ impl Parser { name: tag_name.clone(), bits: bits.clone(), children: Some(children.clone()), - span: Span::new(start_pos, total_length as u16), + span: Span::new(start_pos, 0), // Removed total_length initialization tag_span, }; return Err(ParserError::Ast(AstError::UnexpectedTag(tag), Some(node))); @@ -264,7 +276,7 @@ impl Parser { } } - let span = Span::new(start_pos, total_length as u16); + let span = Span::new(start_pos, 0); // Removed total_length initialization let node = Node::Block { block_type: BlockType::Standard, diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__comments__parse_comments.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__comments__parse_comments.snap index ba19092..f0bd382 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__comments__parse_comments.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__comments__parse_comments.snap @@ -15,5 +15,4 @@ nodes: length: 18 line_offsets: - 0 - - 0 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__comments__parse_comments.snap.new b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__comments__parse_comments.snap.new deleted file mode 100644 index 20b4d11..0000000 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__comments__parse_comments.snap.new +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/djls-template-ast/src/parser.rs -assertion_line: 608 -expression: ast -snapshot_kind: text ---- -nodes: - - Text: - content: "" - span: - start: 0 - length: 21 - - Comment: - content: Django comment - span: - start: 21 - length: 18 -line_offsets: - - 0 -errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_complex_if_elif.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_complex_if_elif.snap index 39f2f54..fcb8d63 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_complex_if_elif.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_complex_if_elif.snap @@ -32,7 +32,7 @@ nodes: length: 8 span: start: 0 - length: 8 + length: 0 tag_span: start: 0 length: 8 @@ -48,7 +48,7 @@ nodes: length: 4 span: start: 0 - length: 8 + length: 0 tag_span: start: 0 length: 8 @@ -59,17 +59,16 @@ nodes: children: ~ span: start: 60 - length: 5 + length: 10 tag_span: start: 0 length: 8 span: start: 0 - length: 65 + length: 70 tag_span: start: 0 length: 8 line_offsets: - 0 - - 0 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_complex_if_elif.snap.new b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_complex_if_elif.snap.new deleted file mode 100644 index b13760e..0000000 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_complex_if_elif.snap.new +++ /dev/null @@ -1,76 +0,0 @@ ---- -source: crates/djls-template-ast/src/parser.rs -assertion_line: 535 -expression: ast -snapshot_kind: text ---- -nodes: - - Block: - block_type: Standard - name: if - bits: - - if - - x - - ">" - - "0" - children: - - Text: - content: Positive - span: - start: 14 - length: 8 - - Block: - block_type: Branch - name: elif - bits: - - x - - "<" - - "0" - children: - - Text: - content: Negative - span: - start: 38 - length: 8 - span: - start: 0 - length: 8 - tag_span: - start: 0 - length: 8 - - Block: - block_type: Branch - name: else - bits: [] - children: - - Text: - content: Zero - span: - start: 56 - length: 4 - span: - start: 0 - length: 8 - tag_span: - start: 0 - length: 8 - - Block: - block_type: Closing - name: endif - bits: [] - children: ~ - span: - start: 60 - length: 5 - tag_span: - start: 0 - length: 8 - span: - start: 0 - length: 65 - tag_span: - start: 0 - length: 8 -line_offsets: - - 0 -errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_for_block.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_for_block.snap index 13feb69..96bd1d0 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_for_block.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_for_block.snap @@ -17,7 +17,7 @@ nodes: - item filters: [] span: - start: 25 + start: 26 length: 4 - Block: block_type: Branch @@ -31,7 +31,7 @@ nodes: length: 8 span: start: 0 - length: 17 + length: 0 tag_span: start: 0 length: 17 @@ -42,17 +42,16 @@ nodes: children: ~ span: start: 52 - length: 6 + length: 11 tag_span: start: 0 length: 17 span: start: 0 - length: 58 + length: 63 tag_span: start: 0 length: 17 line_offsets: - 0 - - 0 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_for_block.snap.new b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_for_block.snap.new deleted file mode 100644 index 9c37553..0000000 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_for_block.snap.new +++ /dev/null @@ -1,59 +0,0 @@ ---- -source: crates/djls-template-ast/src/parser.rs -assertion_line: 527 -expression: ast -snapshot_kind: text ---- -nodes: - - Block: - block_type: Standard - name: for - bits: - - for - - item - - in - - items - children: - - Variable: - bits: - - item - filters: [] - span: - start: 26 - length: 4 - - Block: - block_type: Branch - name: empty - bits: [] - children: - - Text: - content: No items - span: - start: 44 - length: 8 - span: - start: 0 - length: 17 - tag_span: - start: 0 - length: 17 - - Block: - block_type: Closing - name: endfor - bits: [] - children: ~ - span: - start: 52 - length: 6 - tag_span: - start: 0 - length: 17 - span: - start: 0 - length: 58 - tag_span: - start: 0 - length: 17 -line_offsets: - - 0 -errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_if_block.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_if_block.snap index a890b84..963fcbe 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_if_block.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_if_block.snap @@ -22,17 +22,16 @@ nodes: children: ~ span: start: 37 - length: 5 + length: 10 tag_span: start: 0 length: 24 span: start: 0 - length: 42 + length: 47 tag_span: start: 0 length: 24 line_offsets: - 0 - - 0 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_if_block.snap.new b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_if_block.snap.new deleted file mode 100644 index 2f1ae42..0000000 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_if_block.snap.new +++ /dev/null @@ -1,39 +0,0 @@ ---- -source: crates/djls-template-ast/src/parser.rs -assertion_line: 519 -expression: ast -snapshot_kind: text ---- -nodes: - - Block: - block_type: Standard - name: if - bits: - - if - - user.is_authenticated - children: - - Text: - content: Welcome - span: - start: 30 - length: 7 - - Block: - block_type: Closing - name: endif - bits: [] - children: ~ - span: - start: 37 - length: 5 - tag_span: - start: 0 - length: 24 - span: - start: 0 - length: 42 - tag_span: - start: 0 - length: 24 -line_offsets: - - 0 -errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_variable.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_variable.snap index 11a6477..9d52538 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_variable.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_variable.snap @@ -11,12 +11,11 @@ nodes: - name: title arguments: [] span: - start: 12 + start: 10 length: 5 span: - start: 2 + start: 3 length: 15 line_offsets: - 0 - - 0 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_variable.snap.new b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_variable.snap.new deleted file mode 100644 index 471a049..0000000 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_variable.snap.new +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: crates/djls-template-ast/src/parser.rs -assertion_line: 503 -expression: ast -snapshot_kind: text ---- -nodes: - - Variable: - bits: - - user - - name - filters: - - name: title - arguments: [] - span: - start: 10 - length: 5 - span: - start: 3 - length: 15 -line_offsets: - - 0 -errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_filter_chains.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_filter_chains.snap index b19bc54..e0015ff 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_filter_chains.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_filter_chains.snap @@ -11,22 +11,21 @@ nodes: arguments: - "'nothing'" span: - start: 8 + start: 6 length: 17 - name: title arguments: [] span: - start: 26 + start: 24 length: 5 - name: upper arguments: [] span: - start: 32 + start: 30 length: 5 span: - start: 2 + start: 3 length: 35 line_offsets: - 0 - - 0 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_filter_chains.snap.new b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_filter_chains.snap.new deleted file mode 100644 index c42904a..0000000 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_filter_chains.snap.new +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: crates/djls-template-ast/src/parser.rs -assertion_line: 511 -expression: ast -snapshot_kind: text ---- -nodes: - - Variable: - bits: - - value - filters: - - name: default - arguments: - - "'nothing'" - span: - start: 6 - length: 17 - - name: title - arguments: [] - span: - start: 24 - length: 5 - - name: upper - arguments: [] - span: - start: 30 - length: 5 - span: - start: 3 - length: 35 -line_offsets: - - 0 -errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_mixed_content.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_mixed_content.snap index fe5e876..afefbb8 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_mixed_content.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_mixed_content.snap @@ -18,7 +18,7 @@ nodes: - Text: content: "\n " span: - start: 39 + start: 44 length: 5 - Variable: bits: @@ -28,21 +28,21 @@ nodes: - name: title arguments: [] span: - start: 56 + start: 54 length: 5 - name: default arguments: - "'Guest'" span: - start: 62 + start: 60 length: 15 span: - start: 46 + start: 47 length: 31 - Text: content: "\n " span: - start: 81 + start: 86 length: 5 - Block: block_type: Standard @@ -56,7 +56,7 @@ nodes: - Text: content: "\n " span: - start: 116 + start: 125 length: 9 - Block: block_type: Standard @@ -77,20 +77,20 @@ nodes: children: ~ span: start: 148 - length: 5 + length: 10 tag_span: start: 125 length: 16 span: start: 125 - length: 28 + length: 33 tag_span: start: 125 length: 16 - Text: content: "\n " span: - start: 159 + start: 168 length: 9 - Variable: bits: @@ -98,12 +98,12 @@ nodes: - name filters: [] span: - start: 170 + start: 171 length: 10 - Text: content: "\n " span: - start: 184 + start: 193 length: 9 - Block: block_type: Standard @@ -125,20 +125,20 @@ nodes: children: ~ span: start: 220 - length: 5 + length: 10 tag_span: start: 193 length: 19 span: start: 193 - length: 32 + length: 37 tag_span: start: 193 length: 19 - Text: content: "\n " span: - start: 231 + start: 240 length: 9 - Block: block_type: Standard @@ -159,20 +159,20 @@ nodes: children: ~ span: start: 262 - length: 5 + length: 10 tag_span: start: 240 length: 15 span: start: 240 - length: 27 + length: 32 tag_span: start: 240 length: 15 - Text: content: "\n " span: - start: 273 + start: 278 length: 5 - Block: block_type: Branch @@ -182,11 +182,11 @@ nodes: - Text: content: "\n (no groups)\n " span: - start: 289 + start: 298 length: 25 span: start: 86 - length: 24 + length: 0 tag_span: start: 86 length: 24 @@ -197,20 +197,20 @@ nodes: children: ~ span: start: 314 - length: 6 + length: 11 tag_span: start: 86 length: 24 span: start: 86 - length: 234 + length: 239 tag_span: start: 86 length: 24 - Text: content: "\n" span: - start: 326 + start: 327 length: 1 - Block: block_type: Branch @@ -220,11 +220,11 @@ nodes: - Text: content: "\n Guest\n" span: - start: 337 + start: 342 length: 11 span: start: 9 - length: 24 + length: 0 tag_span: start: 9 length: 24 @@ -235,13 +235,13 @@ nodes: children: ~ span: start: 348 - length: 5 + length: 10 tag_span: start: 9 length: 24 span: start: 9 - length: 344 + length: 349 tag_span: start: 9 length: 24 @@ -251,7 +251,6 @@ nodes: start: 359 length: 1 line_offsets: - - 0 - 0 - 40 - 82 diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_mixed_content.snap.new b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_mixed_content.snap.new deleted file mode 100644 index 703a0f7..0000000 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_mixed_content.snap.new +++ /dev/null @@ -1,269 +0,0 @@ ---- -source: crates/djls-template-ast/src/parser.rs -assertion_line: 564 -expression: ast -snapshot_kind: text ---- -nodes: - - Text: - content: "Welcome, " - span: - start: 0 - length: 9 - - Block: - block_type: Standard - name: if - bits: - - if - - user.is_authenticated - children: - - Text: - content: "\n " - span: - start: 39 - length: 5 - - Variable: - bits: - - user - - name - filters: - - name: title - arguments: [] - span: - start: 54 - length: 5 - - name: default - arguments: - - "'Guest'" - span: - start: 60 - length: 15 - span: - start: 47 - length: 31 - - Text: - content: "\n " - span: - start: 81 - length: 5 - - Block: - block_type: Standard - name: for - bits: - - for - - group - - in - - user.groups - children: - - Text: - content: "\n " - span: - start: 116 - length: 9 - - Block: - block_type: Standard - name: if - bits: - - if - - forloop.first - children: - - Text: - content: ( - span: - start: 147 - length: 1 - - Block: - block_type: Closing - name: endif - bits: [] - children: ~ - span: - start: 148 - length: 5 - tag_span: - start: 125 - length: 16 - span: - start: 125 - length: 28 - tag_span: - start: 125 - length: 16 - - Text: - content: "\n " - span: - start: 159 - length: 9 - - Variable: - bits: - - group - - name - filters: [] - span: - start: 171 - length: 10 - - Text: - content: "\n " - span: - start: 184 - length: 9 - - Block: - block_type: Standard - name: if - bits: - - if - - not - - forloop.last - children: - - Text: - content: ", " - span: - start: 218 - length: 2 - - Block: - block_type: Closing - name: endif - bits: [] - children: ~ - span: - start: 220 - length: 5 - tag_span: - start: 193 - length: 19 - span: - start: 193 - length: 32 - tag_span: - start: 193 - length: 19 - - Text: - content: "\n " - span: - start: 231 - length: 9 - - Block: - block_type: Standard - name: if - bits: - - if - - forloop.last - children: - - Text: - content: ) - span: - start: 261 - length: 1 - - Block: - block_type: Closing - name: endif - bits: [] - children: ~ - span: - start: 262 - length: 5 - tag_span: - start: 240 - length: 15 - span: - start: 240 - length: 27 - tag_span: - start: 240 - length: 15 - - Text: - content: "\n " - span: - start: 273 - length: 5 - - Block: - block_type: Branch - name: empty - bits: [] - children: - - Text: - content: "\n (no groups)\n " - span: - start: 289 - length: 25 - span: - start: 86 - length: 24 - tag_span: - start: 86 - length: 24 - - Block: - block_type: Closing - name: endfor - bits: [] - children: ~ - span: - start: 314 - length: 6 - tag_span: - start: 86 - length: 24 - span: - start: 86 - length: 234 - tag_span: - start: 86 - length: 24 - - Text: - content: "\n" - span: - start: 326 - length: 1 - - Block: - block_type: Branch - name: else - bits: [] - children: - - Text: - content: "\n Guest\n" - span: - start: 337 - length: 11 - span: - start: 9 - length: 24 - tag_span: - start: 9 - length: 24 - - Block: - block_type: Closing - name: endif - bits: [] - children: ~ - span: - start: 348 - length: 5 - tag_span: - start: 9 - length: 24 - span: - start: 9 - length: 344 - tag_span: - start: 9 - length: 24 - - Text: - content: "!" - span: - start: 359 - length: 1 -line_offsets: - - 0 - - 40 - - 82 - - 117 - - 160 - - 185 - - 232 - - 274 - - 290 - - 310 - - 327 - - 338 - - 348 -errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_nested_for_if.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_nested_for_if.snap index 8aa150d..1515c31 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_nested_for_if.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_nested_for_if.snap @@ -25,7 +25,7 @@ nodes: - name filters: [] span: - start: 45 + start: 46 length: 9 - Block: block_type: Closing @@ -34,13 +34,13 @@ nodes: children: ~ span: start: 58 - length: 5 + length: 10 tag_span: start: 23 length: 14 span: start: 23 - length: 40 + length: 45 tag_span: start: 23 length: 14 @@ -51,17 +51,16 @@ nodes: children: ~ span: start: 69 - length: 6 + length: 11 tag_span: start: 0 length: 17 span: start: 0 - length: 75 + length: 80 tag_span: start: 0 length: 17 line_offsets: - 0 - - 0 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_nested_for_if.snap.new b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_nested_for_if.snap.new deleted file mode 100644 index f07854c..0000000 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_nested_for_if.snap.new +++ /dev/null @@ -1,68 +0,0 @@ ---- -source: crates/djls-template-ast/src/parser.rs -assertion_line: 544 -expression: ast -snapshot_kind: text ---- -nodes: - - Block: - block_type: Standard - name: for - bits: - - for - - item - - in - - items - children: - - Block: - block_type: Standard - name: if - bits: - - if - - item.active - children: - - Variable: - bits: - - item - - name - filters: [] - span: - start: 46 - length: 9 - - Block: - block_type: Closing - name: endif - bits: [] - children: ~ - span: - start: 58 - length: 5 - tag_span: - start: 23 - length: 14 - span: - start: 23 - length: 40 - tag_span: - start: 23 - length: 14 - - Block: - block_type: Closing - name: endfor - bits: [] - children: ~ - span: - start: 69 - length: 6 - tag_span: - start: 0 - length: 17 - span: - start: 0 - length: 75 - tag_span: - start: 0 - length: 17 -line_offsets: - - 0 -errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_error_recovery.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_error_recovery.snap index dd67046..8dfce30 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_error_recovery.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_error_recovery.snap @@ -18,7 +18,7 @@ nodes: - Text: content: "\n " span: - start: 78 + start: 87 length: 9 - Comment: content: This if is unclosed which does matter @@ -28,7 +28,7 @@ nodes: - Text: content: "\n

Welcome " span: - start: 130 + start: 139 length: 20 - Variable: bits: @@ -36,7 +36,7 @@ nodes: - name filters: [] span: - start: 152 + start: 153 length: 9 - Text: content: "

\n
\n " @@ -51,7 +51,7 @@ nodes: - Text: content: "\n " span: - start: 243 + start: 252 length: 9 - Block: block_type: Standard @@ -65,14 +65,14 @@ nodes: - Text: content: "\n " span: - start: 275 + start: 288 length: 19 - Variable: bits: - item filters: [] span: - start: 296 + start: 297 length: 4 - Text: content: "\n " @@ -86,29 +86,28 @@ nodes: children: ~ span: start: 320 - length: 6 + length: 11 tag_span: start: 252 length: 17 span: start: 252 - length: 74 + length: 79 tag_span: start: 252 length: 17 - Text: content: "\n
Page Footer
\n
" span: - start: 332 + start: 337 length: 40 span: start: 48 - length: 24 + length: 0 tag_span: start: 48 length: 24 line_offsets: - - 0 - 0 - 24 - 44 diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_error_recovery.snap.new b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_error_recovery.snap.new deleted file mode 100644 index 01b9918..0000000 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_error_recovery.snap.new +++ /dev/null @@ -1,126 +0,0 @@ ---- -source: crates/djls-template-ast/src/parser.rs -assertion_line: 677 -expression: ast -snapshot_kind: text ---- -nodes: - - Text: - content: "
\n

Header

\n " - span: - start: 0 - length: 48 - - Block: - block_type: Standard - name: if - bits: - - if - - user.is_authenticated - children: - - Text: - content: "\n " - span: - start: 78 - length: 9 - - Comment: - content: This if is unclosed which does matter - span: - start: 87 - length: 41 - - Text: - content: "\n

Welcome " - span: - start: 130 - length: 20 - - Variable: - bits: - - user - - name - filters: [] - span: - start: 153 - length: 9 - - Text: - content: "

\n
\n " - span: - start: 165 - length: 31 - - Comment: - content: "This div is unclosed which doesn't matter" - span: - start: 196 - length: 45 - - Text: - content: "\n " - span: - start: 243 - length: 9 - - Block: - block_type: Standard - name: for - bits: - - for - - item - - in - - items - children: - - Text: - content: "\n " - span: - start: 275 - length: 19 - - Variable: - bits: - - item - filters: [] - span: - start: 297 - length: 4 - - Text: - content: "\n " - span: - start: 304 - length: 16 - - Block: - block_type: Closing - name: endfor - bits: [] - children: ~ - span: - start: 320 - length: 6 - tag_span: - start: 252 - length: 17 - span: - start: 252 - length: 74 - tag_span: - start: 252 - length: 17 - - Text: - content: "\n
Page Footer
\n
" - span: - start: 332 - length: 40 - span: - start: 48 - length: 24 - tag_span: - start: 48 - length: 24 -line_offsets: - - 0 - - 24 - - 44 - - 79 - - 131 - - 170 - - 184 - - 244 - - 276 - - 312 - - 333 - - 366 -errors: - - UnclosedTag: if diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_django_for.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_django_for.snap index 68ef466..5ee5eb7 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_django_for.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_django_for.snap @@ -18,16 +18,15 @@ nodes: - name filters: [] span: - start: 25 + start: 26 length: 9 span: start: 0 - length: 17 + length: 0 tag_span: start: 0 length: 17 line_offsets: - 0 - - 0 errors: - UnclosedTag: for diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_django_for.snap.new b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_django_for.snap.new deleted file mode 100644 index b94c595..0000000 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_django_for.snap.new +++ /dev/null @@ -1,34 +0,0 @@ ---- -source: crates/djls-template-ast/src/parser.rs -assertion_line: 638 -expression: ast -snapshot_kind: text ---- -nodes: - - Block: - block_type: Standard - name: for - bits: - - for - - item - - in - - items - children: - - Variable: - bits: - - item - - name - filters: [] - span: - start: 26 - length: 9 - span: - start: 0 - length: 17 - tag_span: - start: 0 - length: 17 -line_offsets: - - 0 -errors: - - UnclosedTag: for diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_django_if.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_django_if.snap index 92ef3e9..9097de9 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_django_if.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_django_if.snap @@ -17,12 +17,11 @@ nodes: length: 7 span: start: 0 - length: 24 + length: 0 tag_span: start: 0 length: 24 line_offsets: - 0 - - 0 errors: - UnclosedTag: if diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_django_if.snap.new b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_django_if.snap.new deleted file mode 100644 index 532510a..0000000 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_django_if.snap.new +++ /dev/null @@ -1,29 +0,0 @@ ---- -source: crates/djls-template-ast/src/parser.rs -assertion_line: 628 -expression: ast -snapshot_kind: text ---- -nodes: - - Block: - block_type: Standard - name: if - bits: - - if - - user.is_authenticated - children: - - Text: - content: Welcome - span: - start: 30 - length: 7 - span: - start: 0 - length: 24 - tag_span: - start: 0 - length: 24 -line_offsets: - - 0 -errors: - - UnclosedTag: if diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_html_tag.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_html_tag.snap index ab2ce91..6b42432 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_html_tag.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_html_tag.snap @@ -10,5 +10,4 @@ nodes: length: 5 line_offsets: - 0 - - 0 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_html_tag.snap.new b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_html_tag.snap.new deleted file mode 100644 index e924744..0000000 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_html_tag.snap.new +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: crates/djls-template-ast/src/parser.rs -assertion_line: 619 -expression: ast -snapshot_kind: text ---- -nodes: - - Text: - content: "
" - span: - start: 0 - length: 5 -line_offsets: - - 0 -errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_script.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_script.snap index 457c0f6..1e35fbd 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_script.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_script.snap @@ -10,5 +10,4 @@ nodes: length: 28 line_offsets: - 0 - - 0 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_script.snap.new b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_script.snap.new deleted file mode 100644 index ae9d2b5..0000000 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_script.snap.new +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: crates/djls-template-ast/src/parser.rs -assertion_line: 648 -expression: ast -snapshot_kind: text ---- -nodes: - - Text: - content: "\n \n \n \n
\n " - span: - start: 0 - length: 463 - - Block: - block_type: Standard - name: if - bits: - - if - - user.is_authenticated - children: - - Text: - content: "\n " - span: - start: 493 - length: 17 - - Comment: - content: Welcome message - span: - start: 510 - length: 19 - - Text: - content: "\n

Welcome, " - span: - start: 531 - length: 30 - - Variable: - bits: - - user - - name - filters: - - name: title - arguments: [] - span: - start: 571 - length: 5 - - name: default - arguments: - - "'Guest'" - span: - start: 577 - length: 15 - span: - start: 564 - length: 31 - - Text: - content: "!

\n " - span: - start: 598 - length: 23 - - Block: - block_type: Standard - name: if - bits: - - if - - user.is_staff - children: - - Text: - content: "\n Admin\n " - span: - start: 643 - length: 56 - - Block: - block_type: Branch - name: else - bits: [] - children: - - Text: - content: "\n User\n " - span: - start: 709 - length: 55 - span: - start: 621 - length: 16 - tag_span: - start: 621 - length: 16 - - Block: - block_type: Closing - name: endif - bits: [] - children: ~ - span: - start: 764 - length: 5 - tag_span: - start: 621 - length: 16 - span: - start: 621 - length: 148 - tag_span: - start: 621 - length: 16 - - Text: - content: "\n " - span: - start: 775 - length: 13 - - Block: - block_type: Closing - name: endif - bits: [] - children: ~ - span: - start: 788 - length: 5 - tag_span: - start: 463 - length: 24 - span: - start: 463 - length: 330 - tag_span: - start: 463 - length: 24 - - Text: - content: "\n
\n \n" - span: - start: 799 - length: 35 -line_offsets: - - 0 - - 16 - - 23 - - 34 - - 66 - - 97 - - 134 - - 151 - - 191 - - 215 - - 241 - - 270 - - 298 - - 313 - - 331 - - 343 - - 354 - - 386 - - 451 - - 494 - - 532 - - 605 - - 644 - - 683 - - 710 - - 748 - - 776 - - 800 - - 815 - - 827 -errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_doctype.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_doctype.snap index 4f12506..75261ea 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_doctype.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_doctype.snap @@ -10,5 +10,4 @@ nodes: length: 15 line_offsets: - 0 - - 0 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_doctype.snap.new b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_doctype.snap.new deleted file mode 100644 index 9a0c869..0000000 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_doctype.snap.new +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: crates/djls-template-ast/src/parser.rs -assertion_line: 476 -expression: ast -snapshot_kind: text ---- -nodes: - - Text: - content: "" - span: - start: 0 - length: 15 -line_offsets: - - 0 -errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_tag.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_tag.snap index edad717..57b00d3 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_tag.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_tag.snap @@ -10,5 +10,4 @@ nodes: length: 34 line_offsets: - 0 - - 0 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_tag.snap.new b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_tag.snap.new deleted file mode 100644 index 745d6a6..0000000 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_tag.snap.new +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: crates/djls-template-ast/src/parser.rs -assertion_line: 484 -expression: ast -snapshot_kind: text ---- -nodes: - - Text: - content: "
Hello
" - span: - start: 0 - length: 34 -line_offsets: - - 0 -errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_void.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_void.snap index 59b9455..76523ff 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_void.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_void.snap @@ -10,5 +10,4 @@ nodes: length: 21 line_offsets: - 0 - - 0 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_void.snap.new b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_void.snap.new deleted file mode 100644 index 02b6907..0000000 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_void.snap.new +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: crates/djls-template-ast/src/parser.rs -assertion_line: 492 -expression: ast -snapshot_kind: text ---- -nodes: - - Text: - content: "" - span: - start: 0 - length: 21 -line_offsets: - - 0 -errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__script__parse_script.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__script__parse_script.snap index 34f1dcc..3927d68 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__script__parse_script.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__script__parse_script.snap @@ -9,7 +9,6 @@ nodes: start: 0 length: 142 line_offsets: - - 0 - 0 - 32 - 59 diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__script__parse_script.snap.new b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__script__parse_script.snap.new deleted file mode 100644 index bef0f63..0000000 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__script__parse_script.snap.new +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: crates/djls-template-ast/src/parser.rs -assertion_line: 581 -expression: ast -snapshot_kind: text ---- -nodes: - - Text: - content: "" - span: - start: 0 - length: 142 -line_offsets: - - 0 - - 32 - - 59 - - 76 - - 94 - - 113 - - 133 -errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__style__parse_style.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__style__parse_style.snap index b767351..fc8b64f 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__style__parse_style.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__style__parse_style.snap @@ -9,7 +9,6 @@ nodes: start: 0 length: 97 line_offsets: - - 0 - 0 - 24 - 48 diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__style__parse_style.snap.new b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__style__parse_style.snap.new deleted file mode 100644 index d71036a..0000000 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__style__parse_style.snap.new +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/djls-template-ast/src/parser.rs -assertion_line: 597 -expression: ast -snapshot_kind: text ---- -nodes: - - Text: - content: "" - span: - start: 0 - length: 97 -line_offsets: - - 0 - - 24 - - 48 - - 62 - - 83 - - 89 -errors: []