mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-02 07:20:55 +00:00
Update to rocket 0.5-rc.3
This commit is contained in:
parent
4c98685b81
commit
1856c4b57c
@ -532,18 +532,27 @@ impl<'a> Generator<'a> {
|
||||
// Implement Rocket's `Responder`.
|
||||
#[cfg(feature = "with-rocket")]
|
||||
fn impl_rocket_responder(&mut self, buf: &mut Buffer) -> Result<(), CompileError> {
|
||||
let lifetime = syn::Lifetime::new("'askama", proc_macro2::Span::call_site());
|
||||
let param = syn::GenericParam::Lifetime(syn::LifetimeParam::new(lifetime));
|
||||
let lifetime1 = syn::Lifetime::new("'askama1", proc_macro2::Span::call_site());
|
||||
let lifetime2 = syn::Lifetime::new("'askama2", proc_macro2::Span::call_site());
|
||||
|
||||
let mut param2 = syn::LifetimeParam::new(lifetime2);
|
||||
param2.colon_token = Some(syn::Token));
|
||||
param2.bounds = syn::punctuated::Punctuated::new();
|
||||
param2.bounds.push_value(lifetime1.clone());
|
||||
|
||||
let param1 = syn::GenericParam::Lifetime(syn::LifetimeParam::new(lifetime1));
|
||||
let param2 = syn::GenericParam::Lifetime(param2);
|
||||
|
||||
self.write_header(
|
||||
buf,
|
||||
"::askama_rocket::Responder<'askama, 'askama>",
|
||||
Some(vec![param]),
|
||||
"::askama_rocket::Responder<'askama1, 'askama2>",
|
||||
Some(vec![param1, param2]),
|
||||
)?;
|
||||
|
||||
buf.writeln("#[inline]")?;
|
||||
buf.writeln(
|
||||
"fn respond_to(self, _: &::askama_rocket::Request) \
|
||||
-> ::askama_rocket::Result<'askama> {",
|
||||
"fn respond_to(self, _: &'askama1 ::askama_rocket::Request) \
|
||||
-> ::askama_rocket::Result<'askama2> {",
|
||||
)?;
|
||||
buf.writeln("::askama_rocket::respond(&self)")?;
|
||||
|
||||
|
@ -15,7 +15,7 @@ rust-version = "1.58"
|
||||
|
||||
[dependencies]
|
||||
askama = { version = "0.12", path = "../askama", default-features = false, features = ["with-rocket", "mime", "mime_guess"] }
|
||||
rocket = { version = "0.5.0-rc.2", default-features = false }
|
||||
rocket = { version = "0.5.0-rc.3", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
futures-lite = "1.12.0"
|
||||
|
@ -3,6 +3,7 @@ use askama::Template;
|
||||
use futures_lite::future::block_on;
|
||||
use rocket::http::{ContentType, Status};
|
||||
use rocket::local::asynchronous::Client;
|
||||
use rocket::Responder;
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "hello.html")]
|
||||
@ -10,6 +11,11 @@ struct HelloTemplate<'a> {
|
||||
name: &'a str,
|
||||
}
|
||||
|
||||
#[derive(Responder)]
|
||||
struct HelloResponder<'a> {
|
||||
template: HelloTemplate<'a>,
|
||||
}
|
||||
|
||||
#[rocket::get("/")]
|
||||
fn hello() -> HelloTemplate<'static> {
|
||||
HelloTemplate { name: "world" }
|
||||
|
Loading…
x
Reference in New Issue
Block a user