diff options
Diffstat (limited to '')
-rw-r--r-- | askama/src/filters.rs | 4 | ||||
-rw-r--r-- | askama/src/generator.rs | 7 |
2 files changed, 10 insertions, 1 deletions
diff --git a/askama/src/filters.rs b/askama/src/filters.rs index 17d25c5..a9fe248 100644 --- a/askama/src/filters.rs +++ b/askama/src/filters.rs @@ -43,6 +43,10 @@ pub fn e(s: &fmt::Display) -> String { escape(s) } +/// This is actually unused; format filter calls are forwarded directly to +/// the format!() macro in the code generator (see `visit_filter()`). +pub fn format() { } + #[cfg(test)] mod tests { use super::*; diff --git a/askama/src/generator.rs b/askama/src/generator.rs index 911b860..40b6523 100644 --- a/askama/src/generator.rs +++ b/askama/src/generator.rs @@ -125,7 +125,12 @@ impl<'a> Generator<'a> { } fn visit_filter(&mut self, name: &str, args: &[Expr]) { - self.write(&format!("askama::filters::{}(&", name)); + if name == "format" { + self.write("format!("); + } else { + self.write(&format!("askama::filters::{}(&", name)); + } + for (i, arg) in args.iter().enumerate() { if i > 0 { self.write(", &"); |