diff --git a/leptos/src/for_loop.rs b/leptos/src/for_loop.rs index b571a2e2ee..4c64b39174 100644 --- a/leptos/src/for_loop.rs +++ b/leptos/src/for_loop.rs @@ -44,6 +44,67 @@ use tachys::{reactive_graph::OwnedView, view::keyed::keyed}; /// } /// } /// ``` +/// +/// For convenience, you can also choose to write template code directly in the `` +/// component, using the `let` syntax: +/// +/// ``` +/// # use leptos::prelude::*; +/// +/// # #[derive(Copy, Clone, Debug, PartialEq, Eq)] +/// # struct Counter { +/// # id: usize, +/// # count: RwSignal +/// # } +/// # +/// # #[component] +/// # fn Counters() -> impl IntoView { +/// # let (counters, set_counters) = create_signal::>(vec![]); +/// # +/// view! { +///
+/// +/// +/// +///
+/// } +/// # } +/// ``` +/// +/// The `let` syntax also supports destructuring the pattern of your data. +/// `let((one, two))` in the case of tuples, and `let(Struct { field_one, field_two })` +/// in the case of structs. +/// +/// ``` +/// # use leptos::prelude::*; +/// +/// # #[derive(Copy, Clone, Debug, PartialEq, Eq)] +/// # struct Counter { +/// # id: usize, +/// # count: RwSignal +/// # } +/// # +/// # #[component] +/// # fn Counters() -> impl IntoView { +/// # let (counters, set_counters) = create_signal::>(vec![]); +/// # +/// view! { +///
+/// +/// +/// +///
+/// } +/// # } +/// ``` #[cfg_attr(feature = "tracing", tracing::instrument(level = "trace", skip_all))] #[component] pub fn For(