diff options
Diffstat (limited to '')
| -rw-r--r-- | askama_shared/src/parser.rs | 1 | ||||
| -rw-r--r-- | testing/tests/let_destructoring.rs | 14 | 
2 files changed, 15 insertions, 0 deletions
diff --git a/askama_shared/src/parser.rs b/askama_shared/src/parser.rs index 261887b..d2b2cd1 100644 --- a/askama_shared/src/parser.rs +++ b/askama_shared/src/parser.rs @@ -442,6 +442,7 @@ fn target(i: &[u8]) -> IResult<&[u8], Target<'_>> {      // match structs      let (i, path) = opt(path)(i)?;      if let Some(path) = path { +        let (i, _) = opt(ws(tag("with")))(i)?;          let (i, is_unnamed_struct) = opt_opening_paren(i)?;          if is_unnamed_struct {              let (i, targets) = alt(( diff --git a/testing/tests/let_destructoring.rs b/testing/tests/let_destructoring.rs index 20f7fff..5cb7ae4 100644 --- a/testing/tests/let_destructoring.rs +++ b/testing/tests/let_destructoring.rs @@ -105,3 +105,17 @@ fn test_let_destruct_with_path() {      };      assert_eq!(t.render().unwrap(), "hello");  } + +#[derive(Template)] +#[template(source = "{% let some::path::Struct with (v) = v %}{{v}}", ext = "txt")] +struct LetDestructoringWithPathAndWithKeyword<'a> { +    v: some::path::Struct<'a>, +} + +#[test] +fn test_let_destruct_with_path_and_with_keyword() { +    let t = LetDestructoringWithPathAndWithKeyword { +        v: some::path::Struct("hello"), +    }; +    assert_eq!(t.render().unwrap(), "hello"); +}  | 
