From cc2b8561826b34786cc33994c6725b35660cd6de Mon Sep 17 00:00:00 2001 From: vallentin Date: Tue, 29 Dec 2020 23:53:59 +0100 Subject: Added tojson alias --- askama_shared/src/generator.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'askama_shared') diff --git a/askama_shared/src/generator.rs b/askama_shared/src/generator.rs index ce1ac08..cde0ead 100644 --- a/askama_shared/src/generator.rs +++ b/askama_shared/src/generator.rs @@ -1170,7 +1170,7 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> { fn visit_filter( &mut self, buf: &mut Buffer, - name: &str, + mut name: &str, args: &[Expr], ) -> Result { if name == "format" { @@ -1184,6 +1184,10 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> { return Ok(DisplayWrap::Unwrapped); } + if name == "tojson" { + name = "json"; + } + #[cfg(not(feature = "json"))] if name == "json" { return Err("the `json` filter requires the `serde-json` feature to be enabled".into()); -- cgit