From 4e919e47539b5fa346f1cac323ab250558b834bc Mon Sep 17 00:00:00 2001 From: Lars Erik Rosengren Date: Sun, 10 Sep 2017 20:01:09 +0200 Subject: Add support for tuple indexing in templates --- askama_shared/src/parser.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'askama_shared/src') diff --git a/askama_shared/src/parser.rs b/askama_shared/src/parser.rs index 5de964f..ab79a31 100644 --- a/askama_shared/src/parser.rs +++ b/askama_shared/src/parser.rs @@ -118,8 +118,12 @@ fn identifier(input: &[u8]) -> IResult<&[u8], &str> { IResult::Done(&input[1..], str::from_utf8(&input[..1]).unwrap()) } -named!(expr_num_lit, map!(nom::digit, - |s| Expr::NumLit(str::from_utf8(s).unwrap()) +named!(num_lit<&str>, map!(nom::digit, + |s| str::from_utf8(s).unwrap() +)); + +named!(expr_num_lit, map!(num_lit, + |s| Expr::NumLit(s) )); named!(expr_str_lit, map!( @@ -187,7 +191,7 @@ named!(expr_single, alt!( named!(attr<(&str, Option>)>, do_parse!( tag_s!(".") >> - attr: identifier >> + attr: alt!(num_lit | identifier) >> args: opt!(arguments) >> (attr, args) )); -- cgit