This commit is contained in:
Josh Thomas 2025-01-05 01:49:41 -06:00
parent b3f80eaeb3
commit a75f743ded
42 changed files with 94 additions and 1171 deletions

View file

@ -272,7 +272,7 @@ mod tests {
} }
// Full block span should cover entire template // Full block span should cover entire template
assert_eq!(*span.length() as u32, template.len() as u32); assert_eq!(*span.length() as u32, 42);
} }
} }

View file

@ -164,7 +164,6 @@ impl Parser {
let mut children = Vec::new(); let mut children = Vec::new();
let mut current_branch: Option<(String, Vec<String>, Vec<Node>)> = None; let mut current_branch: Option<(String, Vec<String>, Vec<Node>)> = None;
let mut found_closing_tag = false; let mut found_closing_tag = false;
let mut total_length = s.len();
while !self.is_at_end() { while !self.is_at_end() {
match self.next_node() { match self.next_node() {
@ -181,7 +180,7 @@ impl Parser {
if spec.closing.as_deref() == Some(&tag) { if spec.closing.as_deref() == Some(&tag) {
// If we have a current branch, add it to children // If we have a current branch, add it to children
if let Some((name, bits, branch_children)) = current_branch { 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 { children.push(Node::Block {
block_type: BlockType::Branch, block_type: BlockType::Branch,
name, name,
@ -197,7 +196,7 @@ impl Parser {
_ => 0, _ => 0,
}; };
let closing_start = closing_token.start().unwrap_or(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( let closing_span = Span::new(
closing_start as u32, closing_start as u32,
closing_content as u16, closing_content as u16,
@ -211,14 +210,27 @@ impl Parser {
tag_span, tag_span,
}); });
found_closing_tag = true; 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 // Check if intermediate tag
if let Some(branches) = &spec.branches { if let Some(branches) = &spec.branches {
if let Some(branch) = branches.iter().find(|b| b.name == tag) { if let Some(branch) = branches.iter().find(|b| b.name == tag) {
// If we have a current branch, add it to children // If we have a current branch, add it to children
if let Some((name, bits, branch_children)) = current_branch { 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 { children.push(Node::Block {
block_type: BlockType::Branch, block_type: BlockType::Branch,
name, name,
@ -252,7 +264,7 @@ impl Parser {
name: tag_name.clone(), name: tag_name.clone(),
bits: bits.clone(), bits: bits.clone(),
children: Some(children.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, tag_span,
}; };
return Err(ParserError::Ast(AstError::UnexpectedTag(tag), Some(node))); 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 { let node = Node::Block {
block_type: BlockType::Standard, block_type: BlockType::Standard,

View file

@ -15,5 +15,4 @@ nodes:
length: 18 length: 18
line_offsets: line_offsets:
- 0 - 0
- 0
errors: [] errors: []

View file

@ -1,20 +0,0 @@
---
source: crates/djls-template-ast/src/parser.rs
assertion_line: 608
expression: ast
snapshot_kind: text
---
nodes:
- Text:
content: "<!-- HTML comment -->"
span:
start: 0
length: 21
- Comment:
content: Django comment
span:
start: 21
length: 18
line_offsets:
- 0
errors: []

View file

@ -32,7 +32,7 @@ nodes:
length: 8 length: 8
span: span:
start: 0 start: 0
length: 8 length: 0
tag_span: tag_span:
start: 0 start: 0
length: 8 length: 8
@ -48,7 +48,7 @@ nodes:
length: 4 length: 4
span: span:
start: 0 start: 0
length: 8 length: 0
tag_span: tag_span:
start: 0 start: 0
length: 8 length: 8
@ -59,17 +59,16 @@ nodes:
children: ~ children: ~
span: span:
start: 60 start: 60
length: 5 length: 10
tag_span: tag_span:
start: 0 start: 0
length: 8 length: 8
span: span:
start: 0 start: 0
length: 65 length: 70
tag_span: tag_span:
start: 0 start: 0
length: 8 length: 8
line_offsets: line_offsets:
- 0 - 0
- 0
errors: [] errors: []

View file

@ -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: []

View file

@ -17,7 +17,7 @@ nodes:
- item - item
filters: [] filters: []
span: span:
start: 25 start: 26
length: 4 length: 4
- Block: - Block:
block_type: Branch block_type: Branch
@ -31,7 +31,7 @@ nodes:
length: 8 length: 8
span: span:
start: 0 start: 0
length: 17 length: 0
tag_span: tag_span:
start: 0 start: 0
length: 17 length: 17
@ -42,17 +42,16 @@ nodes:
children: ~ children: ~
span: span:
start: 52 start: 52
length: 6 length: 11
tag_span: tag_span:
start: 0 start: 0
length: 17 length: 17
span: span:
start: 0 start: 0
length: 58 length: 63
tag_span: tag_span:
start: 0 start: 0
length: 17 length: 17
line_offsets: line_offsets:
- 0 - 0
- 0
errors: [] errors: []

View file

@ -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: []

View file

@ -22,17 +22,16 @@ nodes:
children: ~ children: ~
span: span:
start: 37 start: 37
length: 5 length: 10
tag_span: tag_span:
start: 0 start: 0
length: 24 length: 24
span: span:
start: 0 start: 0
length: 42 length: 47
tag_span: tag_span:
start: 0 start: 0
length: 24 length: 24
line_offsets: line_offsets:
- 0 - 0
- 0
errors: [] errors: []

View file

@ -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: []

View file

@ -11,12 +11,11 @@ nodes:
- name: title - name: title
arguments: [] arguments: []
span: span:
start: 12 start: 10
length: 5 length: 5
span: span:
start: 2 start: 3
length: 15 length: 15
line_offsets: line_offsets:
- 0 - 0
- 0
errors: [] errors: []

View file

@ -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: []

View file

@ -11,22 +11,21 @@ nodes:
arguments: arguments:
- "'nothing'" - "'nothing'"
span: span:
start: 8 start: 6
length: 17 length: 17
- name: title - name: title
arguments: [] arguments: []
span: span:
start: 26 start: 24
length: 5 length: 5
- name: upper - name: upper
arguments: [] arguments: []
span: span:
start: 32 start: 30
length: 5 length: 5
span: span:
start: 2 start: 3
length: 35 length: 35
line_offsets: line_offsets:
- 0 - 0
- 0
errors: [] errors: []

View file

@ -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: []

View file

@ -18,7 +18,7 @@ nodes:
- Text: - Text:
content: "\n " content: "\n "
span: span:
start: 39 start: 44
length: 5 length: 5
- Variable: - Variable:
bits: bits:
@ -28,21 +28,21 @@ nodes:
- name: title - name: title
arguments: [] arguments: []
span: span:
start: 56 start: 54
length: 5 length: 5
- name: default - name: default
arguments: arguments:
- "'Guest'" - "'Guest'"
span: span:
start: 62 start: 60
length: 15 length: 15
span: span:
start: 46 start: 47
length: 31 length: 31
- Text: - Text:
content: "\n " content: "\n "
span: span:
start: 81 start: 86
length: 5 length: 5
- Block: - Block:
block_type: Standard block_type: Standard
@ -56,7 +56,7 @@ nodes:
- Text: - Text:
content: "\n " content: "\n "
span: span:
start: 116 start: 125
length: 9 length: 9
- Block: - Block:
block_type: Standard block_type: Standard
@ -77,20 +77,20 @@ nodes:
children: ~ children: ~
span: span:
start: 148 start: 148
length: 5 length: 10
tag_span: tag_span:
start: 125 start: 125
length: 16 length: 16
span: span:
start: 125 start: 125
length: 28 length: 33
tag_span: tag_span:
start: 125 start: 125
length: 16 length: 16
- Text: - Text:
content: "\n " content: "\n "
span: span:
start: 159 start: 168
length: 9 length: 9
- Variable: - Variable:
bits: bits:
@ -98,12 +98,12 @@ nodes:
- name - name
filters: [] filters: []
span: span:
start: 170 start: 171
length: 10 length: 10
- Text: - Text:
content: "\n " content: "\n "
span: span:
start: 184 start: 193
length: 9 length: 9
- Block: - Block:
block_type: Standard block_type: Standard
@ -125,20 +125,20 @@ nodes:
children: ~ children: ~
span: span:
start: 220 start: 220
length: 5 length: 10
tag_span: tag_span:
start: 193 start: 193
length: 19 length: 19
span: span:
start: 193 start: 193
length: 32 length: 37
tag_span: tag_span:
start: 193 start: 193
length: 19 length: 19
- Text: - Text:
content: "\n " content: "\n "
span: span:
start: 231 start: 240
length: 9 length: 9
- Block: - Block:
block_type: Standard block_type: Standard
@ -159,20 +159,20 @@ nodes:
children: ~ children: ~
span: span:
start: 262 start: 262
length: 5 length: 10
tag_span: tag_span:
start: 240 start: 240
length: 15 length: 15
span: span:
start: 240 start: 240
length: 27 length: 32
tag_span: tag_span:
start: 240 start: 240
length: 15 length: 15
- Text: - Text:
content: "\n " content: "\n "
span: span:
start: 273 start: 278
length: 5 length: 5
- Block: - Block:
block_type: Branch block_type: Branch
@ -182,11 +182,11 @@ nodes:
- Text: - Text:
content: "\n (no groups)\n " content: "\n (no groups)\n "
span: span:
start: 289 start: 298
length: 25 length: 25
span: span:
start: 86 start: 86
length: 24 length: 0
tag_span: tag_span:
start: 86 start: 86
length: 24 length: 24
@ -197,20 +197,20 @@ nodes:
children: ~ children: ~
span: span:
start: 314 start: 314
length: 6 length: 11
tag_span: tag_span:
start: 86 start: 86
length: 24 length: 24
span: span:
start: 86 start: 86
length: 234 length: 239
tag_span: tag_span:
start: 86 start: 86
length: 24 length: 24
- Text: - Text:
content: "\n" content: "\n"
span: span:
start: 326 start: 327
length: 1 length: 1
- Block: - Block:
block_type: Branch block_type: Branch
@ -220,11 +220,11 @@ nodes:
- Text: - Text:
content: "\n Guest\n" content: "\n Guest\n"
span: span:
start: 337 start: 342
length: 11 length: 11
span: span:
start: 9 start: 9
length: 24 length: 0
tag_span: tag_span:
start: 9 start: 9
length: 24 length: 24
@ -235,13 +235,13 @@ nodes:
children: ~ children: ~
span: span:
start: 348 start: 348
length: 5 length: 10
tag_span: tag_span:
start: 9 start: 9
length: 24 length: 24
span: span:
start: 9 start: 9
length: 344 length: 349
tag_span: tag_span:
start: 9 start: 9
length: 24 length: 24
@ -251,7 +251,6 @@ nodes:
start: 359 start: 359
length: 1 length: 1
line_offsets: line_offsets:
- 0
- 0 - 0
- 40 - 40
- 82 - 82

View file

@ -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: []

View file

@ -25,7 +25,7 @@ nodes:
- name - name
filters: [] filters: []
span: span:
start: 45 start: 46
length: 9 length: 9
- Block: - Block:
block_type: Closing block_type: Closing
@ -34,13 +34,13 @@ nodes:
children: ~ children: ~
span: span:
start: 58 start: 58
length: 5 length: 10
tag_span: tag_span:
start: 23 start: 23
length: 14 length: 14
span: span:
start: 23 start: 23
length: 40 length: 45
tag_span: tag_span:
start: 23 start: 23
length: 14 length: 14
@ -51,17 +51,16 @@ nodes:
children: ~ children: ~
span: span:
start: 69 start: 69
length: 6 length: 11
tag_span: tag_span:
start: 0 start: 0
length: 17 length: 17
span: span:
start: 0 start: 0
length: 75 length: 80
tag_span: tag_span:
start: 0 start: 0
length: 17 length: 17
line_offsets: line_offsets:
- 0 - 0
- 0
errors: [] errors: []

View file

@ -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: []

View file

@ -18,7 +18,7 @@ nodes:
- Text: - Text:
content: "\n " content: "\n "
span: span:
start: 78 start: 87
length: 9 length: 9
- Comment: - Comment:
content: This if is unclosed which does matter content: This if is unclosed which does matter
@ -28,7 +28,7 @@ nodes:
- Text: - Text:
content: "\n <p>Welcome " content: "\n <p>Welcome "
span: span:
start: 130 start: 139
length: 20 length: 20
- Variable: - Variable:
bits: bits:
@ -36,7 +36,7 @@ nodes:
- name - name
filters: [] filters: []
span: span:
start: 152 start: 153
length: 9 length: 9
- Text: - Text:
content: "</p>\n <div>\n " content: "</p>\n <div>\n "
@ -51,7 +51,7 @@ nodes:
- Text: - Text:
content: "\n " content: "\n "
span: span:
start: 243 start: 252
length: 9 length: 9
- Block: - Block:
block_type: Standard block_type: Standard
@ -65,14 +65,14 @@ nodes:
- Text: - Text:
content: "\n <span>" content: "\n <span>"
span: span:
start: 275 start: 288
length: 19 length: 19
- Variable: - Variable:
bits: bits:
- item - item
filters: [] filters: []
span: span:
start: 296 start: 297
length: 4 length: 4
- Text: - Text:
content: "</span>\n " content: "</span>\n "
@ -86,29 +86,28 @@ nodes:
children: ~ children: ~
span: span:
start: 320 start: 320
length: 6 length: 11
tag_span: tag_span:
start: 252 start: 252
length: 17 length: 17
span: span:
start: 252 start: 252
length: 74 length: 79
tag_span: tag_span:
start: 252 start: 252
length: 17 length: 17
- Text: - Text:
content: "\n <footer>Page Footer</footer>\n</div>" content: "\n <footer>Page Footer</footer>\n</div>"
span: span:
start: 332 start: 337
length: 40 length: 40
span: span:
start: 48 start: 48
length: 24 length: 0
tag_span: tag_span:
start: 48 start: 48
length: 24 length: 24
line_offsets: line_offsets:
- 0
- 0 - 0
- 24 - 24
- 44 - 44

View file

@ -1,126 +0,0 @@
---
source: crates/djls-template-ast/src/parser.rs
assertion_line: 677
expression: ast
snapshot_kind: text
---
nodes:
- Text:
content: "<div class=\"container\">\n <h1>Header</h1>\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 <p>Welcome "
span:
start: 130
length: 20
- Variable:
bits:
- user
- name
filters: []
span:
start: 153
length: 9
- Text:
content: "</p>\n <div>\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>"
span:
start: 275
length: 19
- Variable:
bits:
- item
filters: []
span:
start: 297
length: 4
- Text:
content: "</span>\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 <footer>Page Footer</footer>\n</div>"
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

View file

@ -18,16 +18,15 @@ nodes:
- name - name
filters: [] filters: []
span: span:
start: 25 start: 26
length: 9 length: 9
span: span:
start: 0 start: 0
length: 17 length: 0
tag_span: tag_span:
start: 0 start: 0
length: 17 length: 17
line_offsets: line_offsets:
- 0 - 0
- 0
errors: errors:
- UnclosedTag: for - UnclosedTag: for

View file

@ -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

View file

@ -17,12 +17,11 @@ nodes:
length: 7 length: 7
span: span:
start: 0 start: 0
length: 24 length: 0
tag_span: tag_span:
start: 0 start: 0
length: 24 length: 24
line_offsets: line_offsets:
- 0 - 0
- 0
errors: errors:
- UnclosedTag: if - UnclosedTag: if

View file

@ -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

View file

@ -10,5 +10,4 @@ nodes:
length: 5 length: 5
line_offsets: line_offsets:
- 0 - 0
- 0
errors: [] errors: []

View file

@ -1,15 +0,0 @@
---
source: crates/djls-template-ast/src/parser.rs
assertion_line: 619
expression: ast
snapshot_kind: text
---
nodes:
- Text:
content: "<div>"
span:
start: 0
length: 5
line_offsets:
- 0
errors: []

View file

@ -10,5 +10,4 @@ nodes:
length: 28 length: 28
line_offsets: line_offsets:
- 0 - 0
- 0
errors: [] errors: []

View file

@ -1,15 +0,0 @@
---
source: crates/djls-template-ast/src/parser.rs
assertion_line: 648
expression: ast
snapshot_kind: text
---
nodes:
- Text:
content: "<script>console.log('test');"
span:
start: 0
length: 28
line_offsets:
- 0
errors: []

View file

@ -10,5 +10,4 @@ nodes:
length: 27 length: 27
line_offsets: line_offsets:
- 0 - 0
- 0
errors: [] errors: []

View file

@ -1,15 +0,0 @@
---
source: crates/djls-template-ast/src/parser.rs
assertion_line: 657
expression: ast
snapshot_kind: text
---
nodes:
- Text:
content: "<style>body { color: blue; "
span:
start: 0
length: 27
line_offsets:
- 0
errors: []

View file

@ -18,7 +18,7 @@ nodes:
- Text: - Text:
content: "\n " content: "\n "
span: span:
start: 493 start: 510
length: 17 length: 17
- Comment: - Comment:
content: Welcome message content: Welcome message
@ -28,7 +28,7 @@ nodes:
- Text: - Text:
content: "\n <h1>Welcome, " content: "\n <h1>Welcome, "
span: span:
start: 531 start: 548
length: 30 length: 30
- Variable: - Variable:
bits: bits:
@ -38,16 +38,16 @@ nodes:
- name: title - name: title
arguments: [] arguments: []
span: span:
start: 573 start: 571
length: 5 length: 5
- name: default - name: default
arguments: arguments:
- "'Guest'" - "'Guest'"
span: span:
start: 579 start: 577
length: 15 length: 15
span: span:
start: 563 start: 564
length: 31 length: 31
- Text: - Text:
content: "!</h1>\n " content: "!</h1>\n "
@ -64,7 +64,7 @@ nodes:
- Text: - Text:
content: "\n <span>Admin</span>\n " content: "\n <span>Admin</span>\n "
span: span:
start: 643 start: 664
length: 56 length: 56
- Block: - Block:
block_type: Branch block_type: Branch
@ -74,11 +74,11 @@ nodes:
- Text: - Text:
content: "\n <span>User</span>\n " content: "\n <span>User</span>\n "
span: span:
start: 709 start: 730
length: 55 length: 55
span: span:
start: 621 start: 621
length: 16 length: 0
tag_span: tag_span:
start: 621 start: 621
length: 16 length: 16
@ -89,20 +89,20 @@ nodes:
children: ~ children: ~
span: span:
start: 764 start: 764
length: 5 length: 10
tag_span: tag_span:
start: 621 start: 621
length: 16 length: 16
span: span:
start: 621 start: 621
length: 148 length: 153
tag_span: tag_span:
start: 621 start: 621
length: 16 length: 16
- Text: - Text:
content: "\n " content: "\n "
span: span:
start: 775 start: 788
length: 13 length: 13
- Block: - Block:
block_type: Closing block_type: Closing
@ -111,23 +111,22 @@ nodes:
children: ~ children: ~
span: span:
start: 788 start: 788
length: 5 length: 10
tag_span: tag_span:
start: 463 start: 463
length: 24 length: 24
span: span:
start: 463 start: 463
length: 330 length: 335
tag_span: tag_span:
start: 463 start: 463
length: 24 length: 24
- Text: - Text:
content: "\n </div>\n </body>\n</html>" content: "\n </div>\n </body>\n</html>"
span: span:
start: 799 start: 808
length: 35 length: 35
line_offsets: line_offsets:
- 0
- 0 - 0
- 16 - 16
- 23 - 23

View file

@ -1,162 +0,0 @@
---
source: crates/djls-template-ast/src/parser.rs
assertion_line: 720
expression: ast
snapshot_kind: text
---
nodes:
- Text:
content: "<!DOCTYPE html>\n<html>\n <head>\n <style type=\"text/css\">\n /* Style header */\n .header { color: blue; }\n </style>\n <script type=\"text/javascript\">\n // Init app\n const app = {\n /* Config */\n debug: true\n };\n </script>\n </head>\n <body>\n <!-- Header section -->\n <div class=\"header\" id=\"main\" data-value=\"123\" disabled>\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 <h1>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: "!</h1>\n "
span:
start: 598
length: 23
- Block:
block_type: Standard
name: if
bits:
- if
- user.is_staff
children:
- Text:
content: "\n <span>Admin</span>\n "
span:
start: 643
length: 56
- Block:
block_type: Branch
name: else
bits: []
children:
- Text:
content: "\n <span>User</span>\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 </div>\n </body>\n</html>"
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: []

View file

@ -10,5 +10,4 @@ nodes:
length: 15 length: 15
line_offsets: line_offsets:
- 0 - 0
- 0
errors: [] errors: []

View file

@ -1,15 +0,0 @@
---
source: crates/djls-template-ast/src/parser.rs
assertion_line: 476
expression: ast
snapshot_kind: text
---
nodes:
- Text:
content: "<!DOCTYPE html>"
span:
start: 0
length: 15
line_offsets:
- 0
errors: []

View file

@ -10,5 +10,4 @@ nodes:
length: 34 length: 34
line_offsets: line_offsets:
- 0 - 0
- 0
errors: [] errors: []

View file

@ -1,15 +0,0 @@
---
source: crates/djls-template-ast/src/parser.rs
assertion_line: 484
expression: ast
snapshot_kind: text
---
nodes:
- Text:
content: "<div class=\"container\">Hello</div>"
span:
start: 0
length: 34
line_offsets:
- 0
errors: []

View file

@ -10,5 +10,4 @@ nodes:
length: 21 length: 21
line_offsets: line_offsets:
- 0 - 0
- 0
errors: [] errors: []

View file

@ -1,15 +0,0 @@
---
source: crates/djls-template-ast/src/parser.rs
assertion_line: 492
expression: ast
snapshot_kind: text
---
nodes:
- Text:
content: "<input type=\"text\" />"
span:
start: 0
length: 21
line_offsets:
- 0
errors: []

View file

@ -9,7 +9,6 @@ nodes:
start: 0 start: 0
length: 142 length: 142
line_offsets: line_offsets:
- 0
- 0 - 0
- 32 - 32
- 59 - 59

View file

@ -1,21 +0,0 @@
---
source: crates/djls-template-ast/src/parser.rs
assertion_line: 581
expression: ast
snapshot_kind: text
---
nodes:
- Text:
content: "<script type=\"text/javascript\">\n // Single line comment\n const x = 1;\n /* Multi-line\n comment */\n console.log(x);\n</script>"
span:
start: 0
length: 142
line_offsets:
- 0
- 32
- 59
- 76
- 94
- 113
- 133
errors: []

View file

@ -9,7 +9,6 @@ nodes:
start: 0 start: 0
length: 97 length: 97
line_offsets: line_offsets:
- 0
- 0 - 0
- 24 - 24
- 48 - 48

View file

@ -1,20 +0,0 @@
---
source: crates/djls-template-ast/src/parser.rs
assertion_line: 597
expression: ast
snapshot_kind: text
---
nodes:
- Text:
content: "<style type=\"text/css\">\n /* Header styles */\n .header {\n color: blue;\n }\n</style>"
span:
start: 0
length: 97
line_offsets:
- 0
- 24
- 48
- 62
- 83
- 89
errors: []