mirror of
https://github.com/askama-rs/askama.git
synced 2025-09-30 22:41:13 +00:00
alphabetize frameworks
This commit is contained in:
parent
29cb90bceb
commit
cb60f4e2de
@ -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
|
||||
|
@ -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" }
|
||||
|
@ -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 }
|
||||
|
@ -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"),
|
||||
};
|
||||
|
@ -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(
|
||||
|
@ -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";
|
||||
|
Loading…
x
Reference in New Issue
Block a user