Add parsing of '.' (dot)
Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
parent
9940881e46
commit
145d305c94
1 changed files with 26 additions and 0 deletions
|
|
@ -239,6 +239,7 @@ pub enum TokenOperator {
|
||||||
Lesser,
|
Lesser,
|
||||||
LesserOrEqual,
|
LesserOrEqual,
|
||||||
QuestionMark,
|
QuestionMark,
|
||||||
|
Dot,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||||
|
|
@ -569,6 +570,7 @@ fn parse_operator<'input>(input: &mut Input<'input>) -> PResult<'input, Template
|
||||||
cut_err(fail),
|
cut_err(fail),
|
||||||
)),
|
)),
|
||||||
'?' => empty.value(TokenOperator::QuestionMark),
|
'?' => empty.value(TokenOperator::QuestionMark),
|
||||||
|
'.' => empty.value(TokenOperator::Dot),
|
||||||
_ => fail,
|
_ => fail,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
@ -930,4 +932,28 @@ mod tests {
|
||||||
)
|
)
|
||||||
"#);
|
"#);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_dot() {
|
||||||
|
let input = "{{= foo?.bar }}";
|
||||||
|
let output = parse(input.into());
|
||||||
|
|
||||||
|
insta::assert_debug_snapshot!(output, @r#"
|
||||||
|
Ok(
|
||||||
|
ParsedTemplate {
|
||||||
|
tokens: [
|
||||||
|
[LeftDelim]"{{" (0..2),
|
||||||
|
[WantsOutput]"=" (2..3),
|
||||||
|
[Whitespace]" " (3..4),
|
||||||
|
[Ident]"foo" (4..7),
|
||||||
|
[Operator(QuestionMark)]"?" (7..8),
|
||||||
|
[Operator(Dot)]"." (8..9),
|
||||||
|
[Ident]"bar" (9..12),
|
||||||
|
[Whitespace]" " (12..13),
|
||||||
|
[RightDelim]"}}" (13..15),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
"#);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue