Add deep access
Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
parent
4f770c1f24
commit
ffd9baf90f
9 changed files with 669 additions and 5 deletions
131
tests/cases/deep_access.2-ast.snap
Normal file
131
tests/cases/deep_access.2-ast.snap
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
---
|
||||
source: tests/file_tests.rs
|
||||
expression: ast
|
||||
info:
|
||||
input: "{{ if world?.active }}\nHello {{= world.name }}\n{{ end }}\n\n{{ if world?.foo?.bar?.active }}\n Weird!\n{{ else }}\n Deep access is working :)\n{{ end }}"
|
||||
context:
|
||||
world:
|
||||
active: true
|
||||
name: World!
|
||||
---
|
||||
TemplateAst {
|
||||
root: [
|
||||
ConditionalChain {
|
||||
chain: [
|
||||
Block {
|
||||
prev_whitespace_content: None,
|
||||
expression: IfConditional {
|
||||
expression: AccessOperation {
|
||||
op: Dot,
|
||||
lhs: ConditionalAccess(
|
||||
[Ident]"world" (6..11),
|
||||
),
|
||||
rhs: VariableAccess(
|
||||
[Ident]"active" (13..19),
|
||||
),
|
||||
},
|
||||
},
|
||||
post_whitespace_content: Some(
|
||||
[Whitespace]"\n" (22..23),
|
||||
),
|
||||
},
|
||||
ConditionalContent {
|
||||
content: [
|
||||
StaticContent(
|
||||
[Content]"Hello" (23..28),
|
||||
),
|
||||
Interpolation {
|
||||
prev_whitespace_content: Some(
|
||||
[Whitespace]" " (28..29),
|
||||
),
|
||||
expression: AccessOperation {
|
||||
op: Dot,
|
||||
lhs: VariableAccess(
|
||||
[Ident]"world" (33..38),
|
||||
),
|
||||
rhs: VariableAccess(
|
||||
[Ident]"name" (39..43),
|
||||
),
|
||||
},
|
||||
post_whitespace_content: Some(
|
||||
[Whitespace]"\n" (46..47),
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
Block {
|
||||
prev_whitespace_content: None,
|
||||
expression: EndBlock,
|
||||
post_whitespace_content: Some(
|
||||
[Whitespace]"\n\n" (56..58),
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
ConditionalChain {
|
||||
chain: [
|
||||
Block {
|
||||
prev_whitespace_content: None,
|
||||
expression: IfConditional {
|
||||
expression: AccessOperation {
|
||||
op: Dot,
|
||||
lhs: AccessOperation {
|
||||
op: Dot,
|
||||
lhs: AccessOperation {
|
||||
op: Dot,
|
||||
lhs: ConditionalAccess(
|
||||
[Ident]"world" (64..69),
|
||||
),
|
||||
rhs: ConditionalAccess(
|
||||
[Ident]"foo" (71..74),
|
||||
),
|
||||
},
|
||||
rhs: ConditionalAccess(
|
||||
[Ident]"bar" (76..79),
|
||||
),
|
||||
},
|
||||
rhs: VariableAccess(
|
||||
[Ident]"active" (81..87),
|
||||
),
|
||||
},
|
||||
},
|
||||
post_whitespace_content: Some(
|
||||
[Whitespace]"\n " (90..95),
|
||||
),
|
||||
},
|
||||
ConditionalContent {
|
||||
content: [
|
||||
StaticContent(
|
||||
[Content]"Weird!" (95..101),
|
||||
),
|
||||
],
|
||||
},
|
||||
Block {
|
||||
prev_whitespace_content: Some(
|
||||
[Whitespace]"\n" (101..102),
|
||||
),
|
||||
expression: ElseConditional {
|
||||
expression: None,
|
||||
},
|
||||
post_whitespace_content: Some(
|
||||
[Whitespace]"\n " (112..117),
|
||||
),
|
||||
},
|
||||
ConditionalContent {
|
||||
content: [
|
||||
StaticContent(
|
||||
[Content]"Deep access is working :)" (117..142),
|
||||
),
|
||||
],
|
||||
},
|
||||
Block {
|
||||
prev_whitespace_content: Some(
|
||||
[Whitespace]"\n" (142..143),
|
||||
),
|
||||
expression: EndBlock,
|
||||
post_whitespace_content: None,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue