diff options
Diffstat (limited to '')
-rw-r--r-- | askama_derive/src/generator.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index 9532057..ab1a012 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -97,6 +97,9 @@ impl<'a> Generator<'a> { if cfg!(feature = "gotham") { self.impl_gotham_into_response(&mut buf); } + if cfg!(feature = "warp") { + self.impl_warp_reply(&mut buf); + } buf.buf } @@ -272,6 +275,20 @@ impl<'a> Generator<'a> { buf.writeln("}"); } + fn impl_warp_reply(&mut self, buf: &mut Buffer) { + self.write_header(buf, "::askama_warp::warp::reply::Reply", None); + buf.writeln("fn into_response(self) -> ::askama_warp::warp::reply::Response {"); + let ext = self + .input + .path + .extension() + .and_then(|s| s.to_str()) + .unwrap_or("txt"); + buf.writeln(&format!("::askama_warp::reply(&self, {:?})", ext)); + buf.writeln("}"); + buf.writeln("}"); + } + // Writes header for the `impl` for `TraitFromPathName` or `Template` // for the given context struct. fn write_header( |