diff options
author | vallentin <mail@vallentin.dev> | 2020-12-29 23:02:17 +0100 |
---|---|---|
committer | Christian Vallentin <vallentinsource@gmail.com> | 2020-12-29 23:31:28 +0100 |
commit | 7e9357795a9259ca41eee7249441a920fab8db2f (patch) | |
tree | df0a4208ab7fdcd676d547ee12a6b148709393a9 /askama_shared/src | |
parent | b880799c31ddae53be242c6511794f5d7d35de6e (diff) | |
download | askama-7e9357795a9259ca41eee7249441a920fab8db2f.tar.gz askama-7e9357795a9259ca41eee7249441a920fab8db2f.tar.bz2 askama-7e9357795a9259ca41eee7249441a920fab8db2f.zip |
Added error to hint enabling serde features
Diffstat (limited to 'askama_shared/src')
-rw-r--r-- | askama_shared/src/generator.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/askama_shared/src/generator.rs b/askama_shared/src/generator.rs index b5f98ec..f32542a 100644 --- a/askama_shared/src/generator.rs +++ b/askama_shared/src/generator.rs @@ -1184,6 +1184,15 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> { return Ok(DisplayWrap::Unwrapped); } + #[cfg(not(feature = "json"))] + if name == "json" { + return Err("the `json` filter requires the `serde-json` feature to be enabled".into()); + } + #[cfg(not(feature = "yaml"))] + if name == "yaml" { + return Err("the `yaml` filter requires the `serde-yaml` feature to be enabled".into()); + } + if name == "escape" || name == "safe" || name == "e" || name == "json" { buf.write(&format!( "::askama::filters::{}({}, ", |