Skip to content

Commit

Permalink
Minor changes for ergonomics
Browse files Browse the repository at this point in the history
I've always hated the get_todos function and I
wanted to change it badly. Added a .env file
containing the db url for sqlx-cli, and cleaned
up with leptosfmt
  • Loading branch information
j0lol committed Nov 22, 2023
1 parent 1cd6603 commit a13d655
Show file tree
Hide file tree
Showing 3 changed files with 190 additions and 166 deletions.
1 change: 1 addition & 0 deletions examples/session_auth_axum/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DATABASE_URL=sqlite://Todos.db
33 changes: 16 additions & 17 deletions examples/session_auth_axum/src/error_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,21 @@ pub fn ErrorTemplate(
}

view! {
<h1>"Errors"</h1>
<For
// a function that returns the items we're iterating over; a signal is fine
each= move || {errors.clone().into_iter().enumerate()}
// a unique key for each item as a reference
key=|(index, _error)| *index
// renders each item to a view
children=move |error| {
let error_string = error.1.to_string();
let error_code= error.1.status_code();
view! {

<h2>{error_code.to_string()}</h2>
<p>"Error: " {error_string}</p>
}
}
/>
<h1>"Errors"</h1>
<For
// a function that returns the items we're iterating over; a signal is fine
each=move || { errors.clone().into_iter().enumerate() }
// a unique key for each item as a reference
key=|(index, _error)| *index
// renders each item to a view
children=move |error| {
let error_string = error.1.to_string();
let error_code = error.1.status_code();
view! {
<h2>{error_code.to_string()}</h2>
<p>"Error: " {error_string}</p>
}
}
/>
}
}
Loading

0 comments on commit a13d655

Please sign in to comment.