From b5f771d64b231b9f7fc43b9fe852edbddb861e18 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Fri, 16 Oct 2020 04:30:30 +0500 Subject: [PATCH] Move templates into separate dirs --- src/routes/home.rs | 2 +- src/routes/users.rs | 4 ++-- templates/{ => home}/index.html.hbs | 0 templates/{sign_up.html.hbs => users/new.html.hbs} | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename templates/{ => home}/index.html.hbs (100%) rename templates/{sign_up.html.hbs => users/new.html.hbs} (100%) diff --git a/src/routes/home.rs b/src/routes/home.rs index ed7a666..70b2b01 100644 --- a/src/routes/home.rs +++ b/src/routes/home.rs @@ -7,7 +7,7 @@ use rocket_contrib::templates::Template; pub fn index(db_conn: database::DbConn) -> Result { let all_users = models::User::all(db_conn)?; - Ok(Template::render("index", &IndexTemplateContext { + Ok(Template::render("home/index", &IndexTemplateContext { layout: "site", users: all_users, })) diff --git a/src/routes/users.rs b/src/routes/users.rs index fda73a8..4a980e6 100644 --- a/src/routes/users.rs +++ b/src/routes/users.rs @@ -8,7 +8,7 @@ use rocket_contrib::templates::Template; #[get("/users/new")] pub fn show() -> Template { - Template::render("sign_up", &BasicTemplateContext { + Template::render("users/new", &BasicTemplateContext { layout: "site", }) } @@ -41,7 +41,7 @@ struct BasicTemplateContext { impl From for UserSignUpResponse { fn from(_validation_errors: validator::ValidationErrors) -> Self { - Self::InvalidForm(Template::render("sign_up", &BasicTemplateContext { + Self::InvalidForm(Template::render("users/new", &BasicTemplateContext { layout: "site", })) } diff --git a/templates/index.html.hbs b/templates/home/index.html.hbs similarity index 100% rename from templates/index.html.hbs rename to templates/home/index.html.hbs diff --git a/templates/sign_up.html.hbs b/templates/users/new.html.hbs similarity index 100% rename from templates/sign_up.html.hbs rename to templates/users/new.html.hbs