aboutsummaryrefslogtreecommitdiffstats
path: root/askama_shared
diff options
context:
space:
mode:
authorLibravatar vallentin <mail@vallentin.dev>2020-12-29 23:53:59 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2020-12-30 07:29:40 +0100
commitcc2b8561826b34786cc33994c6725b35660cd6de (patch)
treed2f44ceef70d9ed6a9c07789f0868bba086b1e03 /askama_shared
parent929e9c2bcedb81388ae783a1cb829fbfbaab50dd (diff)
downloadaskama-cc2b8561826b34786cc33994c6725b35660cd6de.tar.gz
askama-cc2b8561826b34786cc33994c6725b35660cd6de.tar.bz2
askama-cc2b8561826b34786cc33994c6725b35660cd6de.zip
Added tojson alias
Diffstat (limited to '')
-rw-r--r--askama_shared/src/generator.rs6
1 files changed, 5 insertions, 1 deletions
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<DisplayWrap, CompileError> {
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());