From 79738ff2388a6f15cd28690a3d276ee5086fb44f Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 18 Jan 2024 10:47:37 +0100 Subject: Fix support for mixed case variables --- testing/tests/simple.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'testing/tests/simple.rs') diff --git a/testing/tests/simple.rs b/testing/tests/simple.rs index f0f0a26..ba806e2 100644 --- a/testing/tests/simple.rs +++ b/testing/tests/simple.rs @@ -484,3 +484,23 @@ fn test_num_literals() { "[90, -90, 90, 2, 56, 240, 10.5, 10.5, 100000000000, 105000000000]", ); } + +#[allow(non_snake_case)] +#[derive(askama::Template)] +#[template(source = "{{ xY }}", ext = "txt")] +struct MixedCase { + xY: &'static str, +} + +/// Test that we can use mixed case in variable names +/// +/// We use some heuristics to distinguish paths (`std::str::String`) from +/// variable names (`foo`). Previously, this test would fail because any +/// name containing uppercase characters would be considered a path. +/// +/// https://github.com/djc/askama/issues/924 +#[test] +fn test_mixed_case() { + let template = MixedCase { xY: "foo" }; + assert_eq!(template.render().unwrap(), "foo"); +} -- cgit