aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Jacob Rothstein <hi@jbr.me>2020-07-13 14:38:56 -0700
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2020-07-14 09:46:12 +0200
commitcb60f4e2dea45f9d6fceb45c8547160a5c8b1a24 (patch)
treef018a5fb0070f8acc493d9fe5ebe8d383182522a
parent29cb90bceb59d9dbea94342dfdd8136e1ef494e6 (diff)
downloadaskama-cb60f4e2dea45f9d6fceb45c8547160a5c8b1a24.tar.gz
askama-cb60f4e2dea45f9d6fceb45c8547160a5c8b1a24.tar.bz2
askama-cb60f4e2dea45f9d6fceb45c8547160a5c8b1a24.zip
alphabetize frameworks
-rw-r--r--README.md2
-rw-r--r--askama/Cargo.toml6
-rw-r--r--askama_derive/Cargo.toml6
-rw-r--r--askama_derive/src/lib.rs2
-rw-r--r--askama_shared/src/generator.rs113
-rw-r--r--askama_shared/src/lib.rs2
6 files changed, 66 insertions, 65 deletions
diff --git a/README.md b/README.md
index e581b09..b6d40ca 100644
--- a/README.md
+++ b/README.md
@@ -30,7 +30,7 @@ in a for-profit context, please consider supporting my open source work on
* Construct templates using a familiar, easy-to-use syntax
* Template code is compiled into your crate for [optimal performance][benchmarks]
* Benefit from the safety provided by Rust's type system
-* Optional built-in support for Actix, Gotham, Iron, Rocket, warp, and tide web frameworks
+* Optional built-in support for Actix, Gotham, Iron, Rocket, tide, and warp web frameworks
* Debugging features to assist you in template development
* Templates must be valid UTF-8 and produce UTF-8 when rendered
* Works on stable Rust
diff --git a/askama/Cargo.toml b/askama/Cargo.toml
index c23f05b..e48faae 100644
--- a/askama/Cargo.toml
+++ b/askama/Cargo.toml
@@ -24,12 +24,12 @@ urlencode = ["askama_shared/percent-encoding"]
serde-json = ["askama_shared/json"]
serde-yaml = ["askama_shared/yaml"]
num-traits = ["askama_shared/num-traits"]
-with-iron = ["askama_derive/iron"]
-with-rocket = ["askama_derive/rocket"]
with-actix-web = ["askama_derive/actix-web"]
with-gotham = ["askama_derive/gotham"]
-with-warp = ["askama_derive/warp"]
+with-iron = ["askama_derive/iron"]
+with-rocket = ["askama_derive/rocket"]
with-tide = ["askama_derive/tide"]
+with-warp = ["askama_derive/warp"]
[dependencies]
askama_derive = { version = "0.10", path = "../askama_derive" }
diff --git a/askama_derive/Cargo.toml b/askama_derive/Cargo.toml
index 99695dd..e5fd82a 100644
--- a/askama_derive/Cargo.toml
+++ b/askama_derive/Cargo.toml
@@ -14,12 +14,12 @@ edition = "2018"
proc-macro = true
[features]
-iron = []
-rocket = []
actix-web = []
gotham = []
-warp = []
+iron = []
+rocket = []
tide = []
+warp = []
[dependencies]
askama_shared = { version = "0.10", path = "../askama_shared", default-features = false }
diff --git a/askama_derive/src/lib.rs b/askama_derive/src/lib.rs
index 2a629d8..2277942 100644
--- a/askama_derive/src/lib.rs
+++ b/askama_derive/src/lib.rs
@@ -89,6 +89,6 @@ const INTEGRATIONS: Integrations = Integrations {
gotham: cfg!(feature = "gotham"),
iron: cfg!(feature = "iron"),
rocket: cfg!(feature = "rocket"),
- warp: cfg!(feature = "warp"),
tide: cfg!(feature = "tide"),
+ warp: cfg!(feature = "warp"),
};
diff --git a/askama_shared/src/generator.rs b/askama_shared/src/generator.rs
index fda56e2..82f68ff 100644
--- a/askama_shared/src/generator.rs
+++ b/askama_shared/src/generator.rs
@@ -94,24 +94,25 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> {
self.impl_template(ctx, &mut buf);
self.impl_display(&mut buf);
- if self.integrations.iron {
- self.impl_modifier_response(&mut buf);
- }
- if self.integrations.rocket {
- self.impl_rocket_responder(&mut buf);
- }
+
if self.integrations.actix {
self.impl_actix_web_responder(&mut buf);
}
if self.integrations.gotham {
self.impl_gotham_into_response(&mut buf);
}
- if self.integrations.warp {
- self.impl_warp_reply(&mut buf);
+ if self.integrations.iron {
+ self.impl_iron_modifier_response(&mut buf);
+ }
+ if self.integrations.rocket {
+ self.impl_rocket_responder(&mut buf);
}
if self.integrations.tide {
self.impl_tide_integrations(&mut buf);
}
+ if self.integrations.warp {
+ self.impl_warp_reply(&mut buf);
+ }
buf.buf
}
@@ -202,8 +203,41 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> {
buf.writeln("}");
}
+ // Implement Actix-web's `Responder`.
+ fn impl_actix_web_responder(&mut self, buf: &mut Buffer) {
+ self.write_header(buf, "::actix_web::Responder", None);
+ buf.writeln("type Future = ::askama_actix::futures::Ready<::std::result::Result<::actix_web::HttpResponse, Self::Error>>;");
+ buf.writeln("type Error = ::actix_web::Error;");
+ buf.writeln(
+ "fn respond_to(self, _req: &::actix_web::HttpRequest) \
+ -> Self::Future {",
+ );
+
+ buf.writeln("use ::askama_actix::TemplateIntoResponse;");
+ buf.writeln("::askama_actix::futures::ready(self.into_response())");
+
+ buf.writeln("}");
+ buf.writeln("}");
+ }
+
+ // Implement gotham's `IntoResponse`.
+ fn impl_gotham_into_response(&mut self, buf: &mut Buffer) {
+ self.write_header(buf, "::askama_gotham::IntoResponse", None);
+ buf.writeln(
+ "fn into_response(self, _state: &::askama_gotham::State)\
+ -> ::askama_gotham::Response<::askama_gotham::Body> {",
+ );
+ let ext = match self.input.path.extension() {
+ Some(s) => s.to_str().unwrap(),
+ None => "txt",
+ };
+ buf.writeln(&format!("::askama_gotham::respond(&self, {:?})", ext));
+ buf.writeln("}");
+ buf.writeln("}");
+ }
+
// Implement iron's Modifier<Response> if enabled
- fn impl_modifier_response(&mut self, buf: &mut Buffer) {
+ fn impl_iron_modifier_response(&mut self, buf: &mut Buffer) {
self.write_header(
buf,
"::askama_iron::Modifier<::askama_iron::Response>",
@@ -254,53 +288,6 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> {
buf.writeln("}");
}
- // Implement Actix-web's `Responder`.
- fn impl_actix_web_responder(&mut self, buf: &mut Buffer) {
- self.write_header(buf, "::actix_web::Responder", None);
- buf.writeln("type Future = ::askama_actix::futures::Ready<::std::result::Result<::actix_web::HttpResponse, Self::Error>>;");
- buf.writeln("type Error = ::actix_web::Error;");
- buf.writeln(
- "fn respond_to(self, _req: &::actix_web::HttpRequest) \
- -> Self::Future {",
- );
-
- buf.writeln("use ::askama_actix::TemplateIntoResponse;");
- buf.writeln("::askama_actix::futures::ready(self.into_response())");
-
- buf.writeln("}");
- buf.writeln("}");
- }
-
- // Implement gotham's `IntoResponse`.
- fn impl_gotham_into_response(&mut self, buf: &mut Buffer) {
- self.write_header(buf, "::askama_gotham::IntoResponse", None);
- buf.writeln(
- "fn into_response(self, _state: &::askama_gotham::State)\
- -> ::askama_gotham::Response<::askama_gotham::Body> {",
- );
- let ext = match self.input.path.extension() {
- Some(s) => s.to_str().unwrap(),
- None => "txt",
- };
- buf.writeln(&format!("::askama_gotham::respond(&self, {:?})", ext));
- buf.writeln("}");
- 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("}");
- }
-
fn impl_tide_integrations(&mut self, buf: &mut Buffer) {
let ext = self
.input
@@ -327,6 +314,20 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> {
buf.writeln("}\n}");
}
+ 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(
diff --git a/askama_shared/src/lib.rs b/askama_shared/src/lib.rs
index f11b129..2e3d502 100644
--- a/askama_shared/src/lib.rs
+++ b/askama_shared/src/lib.rs
@@ -266,8 +266,8 @@ pub struct Integrations {
pub gotham: bool,
pub iron: bool,
pub rocket: bool,
- pub warp: bool,
pub tide: bool,
+ pub warp: bool,
}
static CONFIG_FILE_NAME: &str = "askama.toml";