aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive/src/parser.rs
diff options
context:
space:
mode:
Diffstat (limited to 'askama_derive/src/parser.rs')
-rw-r--r--askama_derive/src/parser.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/askama_derive/src/parser.rs b/askama_derive/src/parser.rs
index b07d8eb..2a6a602 100644
--- a/askama_derive/src/parser.rs
+++ b/askama_derive/src/parser.rs
@@ -26,6 +26,7 @@ pub enum Node<'a> {
Lit(&'a str, &'a str, &'a str),
Comment(),
Expr(WS, Expr<'a>),
+ Let(WS, Target<'a>, Expr<'a>),
Cond(Vec<(WS, Option<Expr<'a>>, Vec<Node<'a>>)>, WS),
Loop(WS, Target<'a>, Expr<'a>, Vec<Node<'a>>, WS),
Extends(Expr<'a>),
@@ -277,6 +278,16 @@ named!(block_if<Node>, do_parse!(
})
));
+named!(block_let<Node>, do_parse!(
+ pws: opt!(tag_s!("-")) >>
+ ws!(tag_s!("let")) >>
+ var: ws!(target_single) >>
+ ws!(tag_s!("=")) >>
+ val: ws!(expr_any) >>
+ nws: opt!(tag_s!("-")) >>
+ (Node::Let(WS(pws.is_some(), nws.is_some()), var, val))
+));
+
named!(block_for<Node>, do_parse!(
pws1: opt!(tag_s!("-")) >>
ws!(tag_s!("for")) >>
@@ -331,6 +342,7 @@ named!(block_include<Node>, do_parse!(
named!(block_node<Node>, do_parse!(
tag_s!("{%") >>
contents: alt!(
+ block_let |
block_if |
block_for |
block_extends |