Update parser to preserve the dot and support paths beginning with a dot.
This commit is contained in:
		
							parent
							
								
									6e8c7621f1
								
							
						
					
					
						commit
						95dc15f103
					
				| @ -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…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander