diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2024-01-18 10:47:37 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2024-01-18 11:23:18 +0100 |
commit | 79738ff2388a6f15cd28690a3d276ee5086fb44f (patch) | |
tree | cfcc54938cfaf09bfbfc1b0e0b25d43463385caf /askama_parser/src | |
parent | 29b25505b496510217a39606a5f72884867ef492 (diff) | |
download | askama-79738ff2388a6f15cd28690a3d276ee5086fb44f.tar.gz askama-79738ff2388a6f15cd28690a3d276ee5086fb44f.tar.bz2 askama-79738ff2388a6f15cd28690a3d276ee5086fb44f.zip |
Fix support for mixed case variables
Diffstat (limited to 'askama_parser/src')
-rw-r--r-- | askama_parser/src/lib.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/askama_parser/src/lib.rs b/askama_parser/src/lib.rs index e6f133c..1cb0e87 100644 --- a/askama_parser/src/lib.rs +++ b/askama_parser/src/lib.rs @@ -349,9 +349,9 @@ fn path_or_identifier(i: &str) -> ParseResult<'_, PathOrIdentifier<'_>> { let rest = rest.as_deref().unwrap_or_default(); // The returned identifier can be assumed to be path if: - // - Contains both a lowercase and uppercase character, i.e. a type name like `None` - // - Doesn't contain any lowercase characters, i.e. it's a constant - // In short, if it contains any uppercase characters it's a path. + // - it is an absolute path (starts with `::`), or + // - it has multiple components (at least one `::`), or + // - the first letter is uppercase match (root, start, rest) { (Some(_), start, tail) => { let mut path = Vec::with_capacity(2 + tail.len()); @@ -360,7 +360,7 @@ fn path_or_identifier(i: &str) -> ParseResult<'_, PathOrIdentifier<'_>> { path.extend(rest); Ok((i, PathOrIdentifier::Path(path))) } - (None, name, []) if !name.contains(char::is_uppercase) => { + (None, name, []) if name.chars().next().map_or(true, |c| c.is_lowercase()) => { Ok((i, PathOrIdentifier::Identifier(name))) } (None, start, tail) => { |