setup htmx to swap (or not) inner html
This commit is contained in:
parent
3fe2c50961
commit
b8e8c0edfa
6 changed files with 23 additions and 9 deletions
|
|
@ -1,10 +1,21 @@
|
|||
use askama::Template;
|
||||
use axum::response::{Html, IntoResponse};
|
||||
use axum::{
|
||||
http::HeaderMap,
|
||||
response::{Html, IntoResponse},
|
||||
};
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "index.html")]
|
||||
struct IndexTemplate;
|
||||
|
||||
pub async fn home() -> impl IntoResponse {
|
||||
Html(IndexTemplate.render().unwrap())
|
||||
#[derive(Template)]
|
||||
#[template(path = "partials/index.html")]
|
||||
struct IndexPartialTemplate;
|
||||
|
||||
pub async fn home(headers: HeaderMap) -> impl IntoResponse {
|
||||
if headers.contains_key("hx-request") {
|
||||
Html(IndexPartialTemplate.render().unwrap())
|
||||
} else {
|
||||
Html(IndexTemplate.render().unwrap())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue