diff options
author | vallentin <mail@vallentin.dev> | 2021-01-11 19:35:33 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2021-01-13 08:58:49 +0100 |
commit | 912bbeb395f183b67eb9500687e865ef24ff62ae (patch) | |
tree | 2a23487ad8b0d09b718ea72c044e4686c48b8b3c /askama_shared/src | |
parent | 560d219c269bbf291a4f78e8ef3ffeb0d02ffdef (diff) | |
download | askama-912bbeb395f183b67eb9500687e865ef24ff62ae.tar.gz askama-912bbeb395f183b67eb9500687e865ef24ff62ae.tar.bz2 askama-912bbeb395f183b67eb9500687e865ef24ff62ae.zip |
Fixed constants (fixes #291)
Diffstat (limited to 'askama_shared/src')
-rw-r--r-- | askama_shared/src/generator.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/askama_shared/src/generator.rs b/askama_shared/src/generator.rs index 801db37..866fd7b 100644 --- a/askama_shared/src/generator.rs +++ b/askama_shared/src/generator.rs @@ -1721,8 +1721,11 @@ impl MapChain<'_, &str, LocalMeta> { } fn resolve_or_self(&self, name: &str) -> String { - self.resolve(name) - .unwrap_or_else(|| format!("self.{}", name)) + match self.resolve(name) { + Some(name) => name, + None if name.chars().any(char::is_uppercase) => name.to_string(), + None => format!("self.{}", name), + } } } |