From 8cc20486c752430a6da50f296e519843b00f61cb Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Sun, 12 Jan 2020 15:44:49 +0100 Subject: Write conditional blocks before popping variable stack (see #227) --- testing/tests/vars.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'testing/tests/vars.rs') 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"); +} -- cgit