Skip to content

Commit

Permalink
Update example to most recent askama release (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
hatzel authored and DoumanAsh committed Mar 17, 2019
1 parent 9d3e64d commit d003fa9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions template_askama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ workspace = "../"

[dependencies]
env_logger = "0.5"
askama = "0.6"
askama = { version = "0.8", features = ["with-actix-web"] }

actix = "0.7"
actix-web = "0.7"

[build-dependencies]
askama = "0.6"
askama = "0.8"
11 changes: 5 additions & 6 deletions template_askama/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::collections::HashMap;

use actix_web::{http, server, App, HttpResponse, Query, Result};
use askama::Template;
use askama::actix_web::TemplateIntoResponse;

#[derive(Template)]
#[template(path = "user.html")]
Expand All @@ -20,16 +21,14 @@ struct UserTemplate<'a> {
struct Index;

fn index(query: Query<HashMap<String, String>>) -> Result<HttpResponse> {
let s = if let Some(name) = query.get("name") {
if let Some(name) = query.get("name") {
UserTemplate {
name: name,
text: "Welcome!",
}.render()
.unwrap()
}.into_response()
} else {
Index.render().unwrap()
};
Ok(HttpResponse::Ok().content_type("text/html").body(s))
Index.into_response()
}
}

fn main() {
Expand Down

0 comments on commit d003fa9

Please sign in to comment.