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
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 current_branch: Option<(String, Vec<String>, Vec<Node>)> = 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,

View file

@ -15,5 +15,4 @@ nodes:
length: 18
line_offsets:
- 0
- 0
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
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: []

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

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

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
arguments: []
span:
start: 12
start: 10
length: 5
span:
start: 2
start: 3
length: 15
line_offsets:
- 0
- 0
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:
- "'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: []

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

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

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:
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 <p>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: "</p>\n <div>\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>"
span:
start: 275
start: 288
length: 19
- Variable:
bits:
- item
filters: []
span:
start: 296
start: 297
length: 4
- Text:
content: "</span>\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 <footer>Page Footer</footer>\n</div>"
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

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

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