diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-08-02 20:59:30 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-08-02 20:59:30 +0200 |
commit | 8ff2e316c07b4fd4373dd8a0bb5747bef3372a32 (patch) | |
tree | 5147b0be34fc45641d5e296c3020e91e6fec6f42 /askama_derive/src/parser.rs | |
parent | 91fe53d9b5db7ace5f82889a174ef5061a049771 (diff) | |
parent | ce84543b69b69ab2030ce4daeae3f26d5008b11d (diff) | |
download | askama-8ff2e316c07b4fd4373dd8a0bb5747bef3372a32.tar.gz askama-8ff2e316c07b4fd4373dd8a0bb5747bef3372a32.tar.bz2 askama-8ff2e316c07b4fd4373dd8a0bb5747bef3372a32.zip |
Merge changes
Diffstat (limited to '')
-rw-r--r-- | askama_derive/src/parser.rs | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/askama_derive/src/parser.rs b/askama_derive/src/parser.rs index 74140bf..61ccb09 100644 --- a/askama_derive/src/parser.rs +++ b/askama_derive/src/parser.rs @@ -156,18 +156,27 @@ named!(expr_single<Expr>, alt!( expr_group )); -named!(expr_attr<Expr>, alt!( - do_parse!( - obj: expr_single >> - tag_s!(".") >> - attr: identifier >> - args: arguments >> - (if args.is_some() { - Expr::Call(Box::new(obj), attr, args.unwrap()) - } else { - Expr::Attr(Box::new(obj), attr) - }) - ) | expr_single +named!(attr<(&str, Option<Vec<Expr>>)>, do_parse!( + tag_s!(".") >> + attr: identifier >> + args: arguments >> + (attr, args) +)); + +named!(expr_attr<Expr>, do_parse!( + obj: expr_single >> + attrs: many0!(attr) >> + ({ + let mut res = obj; + for (aname, args) in attrs { + res = if args.is_some() { + Expr::Call(Box::new(res), aname, args.unwrap()) + } else { + Expr::Attr(Box::new(res), aname) + }; + } + res + }) )); named!(filter<(&str, Option<Vec<Expr>>)>, do_parse!( |