From 7e9357795a9259ca41eee7249441a920fab8db2f Mon Sep 17 00:00:00 2001 From: vallentin Date: Tue, 29 Dec 2020 23:02:17 +0100 Subject: Added error to hint enabling serde features --- askama_shared/src/generator.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'askama_shared') 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::{}({}, ", -- cgit