diff options
author | Lars Erik Rosengren <larserik.rosengren@gmail.com> | 2017-09-10 20:01:09 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-09-10 20:15:15 +0200 |
commit | 4e919e47539b5fa346f1cac323ab250558b834bc (patch) | |
tree | 6adf1b6ae70552892caf708642279f872fd57e0c /askama_shared/src/parser.rs | |
parent | 08bf32b7577b6d2d9638e14980eca286b735c7aa (diff) | |
download | askama-4e919e47539b5fa346f1cac323ab250558b834bc.tar.gz askama-4e919e47539b5fa346f1cac323ab250558b834bc.tar.bz2 askama-4e919e47539b5fa346f1cac323ab250558b834bc.zip |
Add support for tuple indexing in templates
Diffstat (limited to 'askama_shared/src/parser.rs')
-rw-r--r-- | askama_shared/src/parser.rs | 10 |
1 files changed, 7 insertions, 3 deletions
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<Expr>, 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<Expr>, map!(num_lit, + |s| Expr::NumLit(s) )); named!(expr_str_lit<Expr>, map!( @@ -187,7 +191,7 @@ named!(expr_single<Expr>, alt!( named!(attr<(&str, Option<Vec<Expr>>)>, do_parse!( tag_s!(".") >> - attr: identifier >> + attr: alt!(num_lit | identifier) >> args: opt!(arguments) >> (attr, args) )); |