Skip to content

Commit

Permalink
Make empty string literals work
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed Oct 22, 2017
1 parent fef994d commit 14beb21
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion askama_shared/src/parser.rs
Expand Up @@ -146,7 +146,7 @@ named!(expr_array_lit<Expr>, do_parse!(
));

named!(expr_str_lit<Expr>, map!(
delimited!(char!('"'), is_not!("\""), char!('"')),
delimited!(char!('"'), take_until!("\""), char!('"')),
|s| Expr::StrLit(str::from_utf8(s).unwrap())
));

Expand Down
4 changes: 2 additions & 2 deletions testing/tests/simple.rs
Expand Up @@ -187,11 +187,11 @@ fn test_path_compare() {


#[derive(Template)]
#[template(source = "{% for i in [1, 2] %}{{ i }}{% endfor %}", ext = "txt")]
#[template(source = "{% for i in [\"a\", \"\"] %}{{ i }}{% endfor %}", ext = "txt")]
struct ArrayTemplate {}

#[test]
fn test_slice_literal() {
let t = ArrayTemplate {};
assert_eq!(t.render().unwrap(), "12");
assert_eq!(t.render().unwrap(), "a");
}

0 comments on commit 14beb21

Please sign in to comment.