Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust 1.50 #448

Merged
merged 2 commits into from
Feb 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions askama/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "askama"
version = "0.10.5"
version = "0.10.6"
authors = ["Dirkjan Ochtman <dirkjan@ochtman.nl>"]
description = "Type-safe, compiled Jinja-like templates for Rust"
documentation = "https://docs.rs/askama"
Expand Down Expand Up @@ -35,7 +35,7 @@ with-warp = ["askama_derive/warp"]
[dependencies]
askama_derive = { version = "0.10.5", path = "../askama_derive" }
askama_escape = { version = "0.10", path = "../askama_escape" }
askama_shared = { version = "0.11", path = "../askama_shared", default-features = false }
askama_shared = { version = "0.11.2", path = "../askama_shared", default-features = false }
mime = { version = "0.3", optional = true }
mime_guess = { version = "2.0.0-alpha", optional = true }

Expand Down
2 changes: 1 addition & 1 deletion askama_actix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ edition = "2018"

[dependencies]
actix-web = { version = "3", default-features = false }
askama = { version = "0.10", path = "../askama", default-features = false, features = ["with-actix-web", "mime", "mime_guess"] }
askama = { version = "0.10.6", path = "../askama", default-features = false, features = ["with-actix-web", "mime", "mime_guess"] }
bytes = { version = "0.5" }
futures-util = { version = "0.3" }

Expand Down
8 changes: 4 additions & 4 deletions askama_actix/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ use bytes::BytesMut;

use actix_web::{error::ErrorInternalServerError, Error, HttpResponse};

pub trait TemplateIntoResponse {
fn into_response(&self) -> ::std::result::Result<HttpResponse, Error>;
pub trait TemplateToResponse {
fn to_response(&self) -> ::std::result::Result<HttpResponse, Error>;
}

impl<T: askama::Template> TemplateIntoResponse for T {
fn into_response(&self) -> ::std::result::Result<HttpResponse, Error> {
impl<T: askama::Template> TemplateToResponse for T {
fn to_response(&self) -> ::std::result::Result<HttpResponse, Error> {
let mut buffer = BytesMut::with_capacity(self.size_hint());
self.render_into(&mut buffer)
.map_err(|_| ErrorInternalServerError("Template parsing error"))?;
Expand Down
4 changes: 2 additions & 2 deletions askama_actix/tests/basic.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use actix_web::http::header::CONTENT_TYPE;
use actix_web::test;
use actix_web::web;
use askama_actix::{Template, TemplateIntoResponse};
use askama_actix::{Template, TemplateToResponse};
use bytes::Bytes;

#[derive(Template)]
Expand Down Expand Up @@ -34,7 +34,7 @@ async fn test_actix_web_responder() {
let srv = test::start(|| {
actix_web::App::new().service(web::resource("/").to(|| async {
let name = "world".to_owned();
HelloTemplate { name: &name }.into_response()
HelloTemplate { name: &name }.to_response()
}))
});

Expand Down
2 changes: 1 addition & 1 deletion askama_shared/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "askama_shared"
version = "0.11.1"
version = "0.11.2"
authors = ["Dirkjan Ochtman <dirkjan@ochtman.nl>"]
description = "Shared code for Askama"
homepage = "https://github.com/djc/askama"
Expand Down
14 changes: 8 additions & 6 deletions askama_shared/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> {
-> Self::Future {",
)?;

buf.writeln("use ::askama_actix::TemplateIntoResponse;")?;
buf.writeln("::askama_actix::futures::ready(self.into_response())")?;
buf.writeln("use ::askama_actix::TemplateToResponse;")?;
buf.writeln("::askama_actix::futures::ready(self.to_response())")?;

buf.writeln("}")?;
buf.writeln("}")
Expand Down Expand Up @@ -1283,11 +1283,13 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> {
buf.write("&(");
}

let scoped = matches!(arg,
let scoped = matches!(
arg,
Expr::Filter(_, _)
| Expr::MethodCall(_, _, _)
| Expr::VarCall(_, _)
| Expr::PathCall(_, _));
| Expr::MethodCall(_, _, _)
| Expr::VarCall(_, _)
| Expr::PathCall(_, _)
);

if scoped {
buf.writeln("{")?;
Expand Down