diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2020-01-12 15:44:49 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2020-01-12 15:44:49 +0100 |
commit | 8cc20486c752430a6da50f296e519843b00f61cb (patch) | |
tree | 2e826b21b80d8a4f73f7ae832b02ee1000791a1c /testing/tests/vars.rs | |
parent | 80148aa75335563106abae8680197e4adf3eb2eb (diff) | |
download | askama-8cc20486c752430a6da50f296e519843b00f61cb.tar.gz askama-8cc20486c752430a6da50f296e519843b00f61cb.tar.bz2 askama-8cc20486c752430a6da50f296e519843b00f61cb.zip |
Write conditional blocks before popping variable stack (see #227)
Diffstat (limited to '')
-rw-r--r-- | testing/tests/vars.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/testing/tests/vars.rs b/testing/tests/vars.rs index 3af41c6..d1c41f9 100644 --- a/testing/tests/vars.rs +++ b/testing/tests/vars.rs @@ -55,3 +55,18 @@ fn test_self_iter() { let t = SelfIterTemplate(vec![1, 2, 3]); assert_eq!(t.render().unwrap(), "123"); } + +#[derive(Template)] +#[template( + source = "{% if true %}{% let t = a.unwrap() %}{{ t }}{% endif %}", + ext = "txt" +)] +struct IfLet { + a: Option<&'static str>, +} + +#[test] +fn test_if_let() { + let t = IfLet { a: Some("foo") }; + assert_eq!(t.render().unwrap(), "foo"); +} |