aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--askama/src/generator.rs1
-rw-r--r--askama/src/parser.rs11
2 files changed, 11 insertions, 1 deletions
diff --git a/askama/src/generator.rs b/askama/src/generator.rs
index 6975f25..dcd50e8 100644
--- a/askama/src/generator.rs
+++ b/askama/src/generator.rs
@@ -316,6 +316,7 @@ impl<'a> Generator<'a> {
for n in nodes {
match *n {
Node::Lit(lws, val, rws) => { self.write_lit(lws, val, rws); }
+ Node::Comment() => {},
Node::Expr(ref ws, ref val) => { self.write_expr(ws, val); },
Node::Cond(ref conds, ref ws) => {
self.write_cond(conds, ws);
diff --git a/askama/src/parser.rs b/askama/src/parser.rs
index b955f0a..ce13add 100644
--- a/askama/src/parser.rs
+++ b/askama/src/parser.rs
@@ -24,6 +24,7 @@ pub struct WS(pub bool, pub bool);
#[derive(Debug)]
pub enum Node<'a> {
Lit(&'a str, &'a str, &'a str),
+ Comment(),
Expr(WS, Expr<'a>),
Cond(Vec<(WS, Option<Expr<'a>>, Vec<Node<'a>>)>, WS),
Loop(WS, Target<'a>, Expr<'a>, Vec<Node<'a>>, WS),
@@ -68,7 +69,7 @@ fn take_content(i: &[u8]) -> IResult<&[u8], Node> {
if *c == b'{' {
if i.len() < j + 2 {
return IResult::Done(&i[..0], split_ws_parts(&i[..]));
- } else if i[j + 1] == b'{' || i[j + 1] == b'%' {
+ } else if i[j + 1] == b'{' || i[j + 1] == b'%' || i[j + 1] == b'#' {
return IResult::Done(&i[j..], split_ws_parts(&i[..j]));
}
}
@@ -299,8 +300,16 @@ named!(block_block<Node>, do_parse!(
WS(pws2.is_some(), pws2.is_some())))
));
+named!(block_comment<Node>, do_parse!(
+ tag_s!("{#") >>
+ take_until_s!("#}") >>
+ tag_s!("#}") >>
+ (Node::Comment())
+));
+
named!(parse_template<Vec<Node<'a>>>, many0!(alt!(
take_content |
+ block_comment |
expr_node |
block_if |
block_for |