Use handlebars to render index
[?]
Feb 17, 2021, 3:06 PM
65A3LIWUS7UNMIHACC7ED6SSSSGQMKW4SAHQLXMT2YT6PFJ7KVUQCDependencies
- [2]
OJO4B4QOAdd login form and empty handler - [3]
BCXEUKX6Add config, static files and web server - [*]
4MZ4VIR7Initial commit
Change contents
- file addition: templates[5.6]
- file move: index.html → index.html
- edit in src/main.rs at line 2
use actix_web::{middleware, web, App, HttpResponse, HttpServer}; - replacement in src/main.rs at line 5
use actix_web::{middleware, web, App, HttpServer};use handlebars::Handlebars; - edit in src/main.rs at line 12
async fn index(hb: web::Data<Handlebars<'_>>) -> HttpResponse {let body = hb.render("index", &()).expect("render index");HttpResponse::Ok().body(body)} - edit in src/main.rs at line 40
let mut handlebars = Handlebars::new();handlebars.set_strict_mode(true);handlebars.register_template_string("index", include_str!("templates/index.html")).expect("index template");let handlebars_ref = web::Data::new(handlebars); - edit in src/main.rs at line 51
.app_data(handlebars_ref.clone()).route("/", web::get().to(index)).route("/index.html", web::get().to(index))