mirror of
https://github.com/actix/examples
synced 2025-06-28 18:00:37 +02:00
Update yarte to 0.15 (#416)
This commit is contained in:
@ -8,8 +8,7 @@ edition = "2018"
|
||||
[dependencies]
|
||||
actix-web = "3"
|
||||
env_logger = "0.8"
|
||||
# TODO: remove fixed feature. Is a bug.
|
||||
yarte = { version = "0.12", features = ["bytes-buf", "html-min", "fixed"] }
|
||||
yarte = { version = "0.15", features = ["bytes-buf", "html-min"] }
|
||||
derive_more = "0.99"
|
||||
|
||||
[build-dependencies.yarte_helpers]
|
||||
|
@ -4,7 +4,7 @@ use actix_web::{
|
||||
get, middleware::Logger, web, App, Error, HttpResponse, HttpServer, ResponseError,
|
||||
};
|
||||
use derive_more::Display;
|
||||
use yarte::ywrite_min;
|
||||
use yarte::{auto, ywrite_min};
|
||||
|
||||
#[derive(Debug, Display)]
|
||||
struct MyErr(pub &'static str);
|
||||
@ -15,14 +15,11 @@ impl ResponseError for MyErr {}
|
||||
async fn index(
|
||||
query: web::Query<HashMap<String, String>>,
|
||||
) -> Result<HttpResponse, Error> {
|
||||
let mut body = web::BytesMut::with_capacity(512);
|
||||
// `ywrite_min` is work in progress check your templates before put in production
|
||||
// or use `ywrite_html`
|
||||
ywrite_min!(body, "{{> index }}");
|
||||
|
||||
Ok(HttpResponse::Ok()
|
||||
.content_type("text/html; charset=utf-8")
|
||||
.body(body))
|
||||
.body(auto!(ywrite_min!(String, "{{> index }}"))))
|
||||
}
|
||||
|
||||
#[actix_web::main]
|
||||
|
Reference in New Issue
Block a user