From a199defeca2dfc6aa3e972acca82c96db07f99e9 Mon Sep 17 00:00:00 2001 From: Christian Vallentin Date: Tue, 1 Dec 2020 17:01:05 +0100 Subject: Improved if statement generation to avoid issues with implicit borrows (#392) * Changed to automatically coerce to bool * Added new test case * Updated test case to include else if --- testing/tests/coerce.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 testing/tests/coerce.rs (limited to 'testing/tests') diff --git a/testing/tests/coerce.rs b/testing/tests/coerce.rs new file mode 100644 index 0000000..1a44781 --- /dev/null +++ b/testing/tests/coerce.rs @@ -0,0 +1,14 @@ +use askama::Template; + +#[derive(Template)] +#[template(path = "if-coerce.html")] +struct IfCoerceTemplate { + t: bool, + f: bool, +} + +#[test] +fn test_coerce() { + let t = IfCoerceTemplate { t: true, f: false }; + assert_eq!(t.render().unwrap(), "ftftfttftelseifelseif"); +} -- cgit