aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@blos.sm>2024-01-24 20:23:18 +0000
committerLibravatar cel 🌸 <cel@blos.sm>2024-01-24 20:23:18 +0000
commitd3b048544eebf7b8402fb585b4e2531de9b28a33 (patch)
tree2e697063854d22aff603ba3691c6453ddf5cd87b /askama_derive
parentef53238ae2ee77becc44bcb0b77c1c4daceca5af (diff)
downloadaskama-main.tar.gz
askama-main.tar.bz2
askama-main.zip
Add poem integrationHEADmain
Diffstat (limited to 'askama_derive')
-rw-r--r--askama_derive/Cargo.toml1
-rw-r--r--askama_derive/src/generator.rs16
2 files changed, 17 insertions, 0 deletions
diff --git a/askama_derive/Cargo.toml b/askama_derive/Cargo.toml
index 183958a..7cc830a 100644
--- a/askama_derive/Cargo.toml
+++ b/askama_derive/Cargo.toml
@@ -26,6 +26,7 @@ with-axum = []
with-gotham = []
with-hyper = []
with-mendes = []
+with-poem = []
with-rocket = []
with-tide = []
with-warp = []
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs
index 22f996f..1a2537e 100644
--- a/askama_derive/src/generator.rs
+++ b/askama_derive/src/generator.rs
@@ -74,6 +74,8 @@ impl<'a> Generator<'a> {
self.impl_hyper_into_response(&mut buf)?;
#[cfg(feature = "with-mendes")]
self.impl_mendes_responder(&mut buf)?;
+ #[cfg(feature = "with-poem")]
+ self.impl_poem_into_response(&mut buf)?;
#[cfg(feature = "with-rocket")]
self.impl_rocket_responder(&mut buf)?;
#[cfg(feature = "with-tide")]
@@ -284,6 +286,20 @@ impl<'a> Generator<'a> {
Ok(())
}
+ // Implement Poem's `IntoResponse`.
+ #[cfg(feature = "with-poem")]
+ fn impl_poem_into_response(&mut self, buf: &mut Buffer) -> Result<(), CompileError> {
+ self.write_header(buf, "::askama_poem::IntoResponse", None)?;
+ buf.writeln("#[inline]")?;
+ buf.writeln(
+ "fn into_response(self)\
+ -> ::askama_poem::Response {",
+ )?;
+ buf.writeln("::askama_poem::into_response(&self)")?;
+ buf.writeln("}")?;
+ buf.writeln("}")
+ }
+
// Implement Rocket's `Responder`.
#[cfg(feature = "with-rocket")]
fn impl_rocket_responder(&mut self, buf: &mut Buffer) -> Result<(), CompileError> {