Update parser to preserve the dot and support paths beginning with a dot.

master
Tom Alexander 4 years ago
parent 6e8c7621f1
commit 95dc15f103
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

@ -263,7 +263,14 @@ fn key(i: &str) -> IResult<&str, &str> {
fn path(i: &str) -> IResult<&str, Path> {
alt((
map(separated_list1(tag("."), key), |body| Path { keys: body }),
value(Path { keys: Vec::new() }, tag(".")),
map(
tuple((tag("."), separated_list1(tag("."), key))),
|(dot, mut body)| {
body.insert(0, dot);
Path { keys: body }
},
),
map(tag("."), |dot| Path { keys: vec![dot] }),
))(i)
}
@ -1210,7 +1217,7 @@ mod tests {
contents: Some(Body {
elements: vec![TemplateElement::TETag(DustTag::DTReference(
Reference {
path: Path { keys: vec![] },
path: Path { keys: vec!["."] },
filters: vec![]
}
))]
@ -1238,7 +1245,7 @@ mod tests {
IgnoredWhitespace::StartOfLine("\n")
),
TemplateElement::TETag(DustTag::DTReference(Reference {
path: Path { keys: vec![] },
path: Path { keys: vec!["."] },
filters: vec![]
})),
TemplateElement::TEIgnoredWhitespace(

Loading…
Cancel
Save