From 3f2a9facf894a15babc9ec8b745471443cd0698c Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Tue, 26 Sep 2023 14:24:02 -0400 Subject: [PATCH] change: enable inline children for `For` by switching to `children` and `bind:` (#1773) --- benchmarks/src/todomvc/leptos.rs | 2 +- docs/book/src/router/17_nested_routing.md | 4 +- examples/counters/src/lib.rs | 2 +- examples/counters_stable/src/lib.rs | 2 +- examples/errors_axum/src/error_template.rs | 2 +- examples/hackernews/src/routes/stories.rs | 10 ++-- examples/hackernews/src/routes/story.rs | 12 ++-- .../hackernews_axum/src/error_template.rs | 2 +- .../hackernews_axum/src/routes/stories.rs | 10 ++-- examples/hackernews_axum/src/routes/story.rs | 12 ++-- .../src/error_template.rs | 2 +- .../src/routes/stories.rs | 10 ++-- .../hackernews_js_fetch/src/error_template.rs | 2 +- .../hackernews_js_fetch/src/routes/stories.rs | 10 ++-- .../hackernews_js_fetch/src/routes/story.rs | 12 ++-- examples/js-framework-benchmark/src/lib.rs | 2 +- .../session_auth_axum/src/error_template.rs | 2 +- .../src/error_template.rs | 2 +- .../todo_app_sqlite_viz/src/error_template.rs | 2 +- examples/todomvc/src/lib.rs | 6 +- leptos/src/for_loop.rs | 57 +++++++++++++++++-- 21 files changed, 110 insertions(+), 55 deletions(-) diff --git a/benchmarks/src/todomvc/leptos.rs b/benchmarks/src/todomvc/leptos.rs index 97e36c210..aed57ed8d 100644 --- a/benchmarks/src/todomvc/leptos.rs +++ b/benchmarks/src/todomvc/leptos.rs @@ -192,7 +192,7 @@ pub fn TodoMVC(todos: Todos) -> impl IntoView { } } /> diff --git a/docs/book/src/router/17_nested_routing.md b/docs/book/src/router/17_nested_routing.md index 340ebbe57..82ca0961a 100644 --- a/docs/book/src/router/17_nested_routing.md +++ b/docs/book/src/router/17_nested_routing.md @@ -143,8 +143,8 @@ pub fn ContactList() -> impl IntoView { // the contact list + children=|contact| todo!() + /> // the nested child, if any // don’t forget this! diff --git a/examples/counters/src/lib.rs b/examples/counters/src/lib.rs index a05c76060..b154be3b6 100644 --- a/examples/counters/src/lib.rs +++ b/examples/counters/src/lib.rs @@ -65,7 +65,7 @@ pub fn Counters() -> impl IntoView { , WriteSignal))| { + children=move |(id, (value, set_value)): (usize, (ReadSignal, WriteSignal))| { view! { } diff --git a/examples/counters_stable/src/lib.rs b/examples/counters_stable/src/lib.rs index e09a38a01..35e31bdd4 100644 --- a/examples/counters_stable/src/lib.rs +++ b/examples/counters_stable/src/lib.rs @@ -67,7 +67,7 @@ pub fn Counters() -> impl IntoView { } diff --git a/examples/errors_axum/src/error_template.rs b/examples/errors_axum/src/error_template.rs index 5badfd119..045ff1c78 100644 --- a/examples/errors_axum/src/error_template.rs +++ b/examples/errors_axum/src/error_template.rs @@ -45,7 +45,7 @@ pub fn ErrorTemplate( // a unique key for each item as a reference key=|(index, _)| *index // renders each item to a view - view=move |error| { + children=move |error| { let error_string = error.1.to_string(); let error_code= error.1.status_code(); view! { diff --git a/examples/hackernews/src/routes/stories.rs b/examples/hackernews/src/routes/stories.rs index 94f0689d1..0fe0ef2fb 100644 --- a/examples/hackernews/src/routes/stories.rs +++ b/examples/hackernews/src/routes/stories.rs @@ -91,12 +91,10 @@ pub fn Stories() -> impl IntoView { - } - } - /> + let:story + > + + }.into_any()) } diff --git a/examples/hackernews/src/routes/story.rs b/examples/hackernews/src/routes/story.rs index 313d024f6..c63dafc04 100644 --- a/examples/hackernews/src/routes/story.rs +++ b/examples/hackernews/src/routes/story.rs @@ -57,8 +57,10 @@ pub fn Story() -> impl IntoView { } - /> + let:comment + > + + @@ -100,8 +102,10 @@ pub fn Comment(comment: api::Comment) -> impl IntoView { } - /> + let:comment + > + + } })} diff --git a/examples/hackernews_axum/src/error_template.rs b/examples/hackernews_axum/src/error_template.rs index 413d94946..58a8af2ef 100644 --- a/examples/hackernews_axum/src/error_template.rs +++ b/examples/hackernews_axum/src/error_template.rs @@ -15,7 +15,7 @@ pub fn error_template(errors: Option>) -> View { // a unique key for each item as a reference key=|(key, _)| key.clone() // renders each item to a view - view= move | (_, error)| { + children=move | (_, error)| { let error_string = error.to_string(); view! { diff --git a/examples/hackernews_axum/src/routes/stories.rs b/examples/hackernews_axum/src/routes/stories.rs index 62a309495..150ce2192 100644 --- a/examples/hackernews_axum/src/routes/stories.rs +++ b/examples/hackernews_axum/src/routes/stories.rs @@ -90,12 +90,10 @@ pub fn Stories() -> impl IntoView { - } - } - /> + let:story + > + + }.into_any()) } diff --git a/examples/hackernews_axum/src/routes/story.rs b/examples/hackernews_axum/src/routes/story.rs index edeaa9073..00449a03a 100644 --- a/examples/hackernews_axum/src/routes/story.rs +++ b/examples/hackernews_axum/src/routes/story.rs @@ -57,8 +57,10 @@ pub fn Story() -> impl IntoView { } - /> + let:comment + > + + @@ -100,8 +102,10 @@ pub fn Comment(comment: api::Comment) -> impl IntoView { } - /> + let:comment + > + + } })} diff --git a/examples/hackernews_islands_axum/src/error_template.rs b/examples/hackernews_islands_axum/src/error_template.rs index 413d94946..b1bd543d2 100644 --- a/examples/hackernews_islands_axum/src/error_template.rs +++ b/examples/hackernews_islands_axum/src/error_template.rs @@ -15,7 +15,7 @@ pub fn error_template(errors: Option>) -> View { // a unique key for each item as a reference key=|(key, _)| key.clone() // renders each item to a view - view= move | (_, error)| { + children= move | (_, error)| { let error_string = error.to_string(); view! { diff --git a/examples/hackernews_islands_axum/src/routes/stories.rs b/examples/hackernews_islands_axum/src/routes/stories.rs index 147153a08..f6ddac144 100644 --- a/examples/hackernews_islands_axum/src/routes/stories.rs +++ b/examples/hackernews_islands_axum/src/routes/stories.rs @@ -98,12 +98,10 @@ pub fn Stories() -> impl IntoView { - } - } - /> + let:story + > + + }))} diff --git a/examples/hackernews_js_fetch/src/error_template.rs b/examples/hackernews_js_fetch/src/error_template.rs index 2937f8928..adad9489c 100644 --- a/examples/hackernews_js_fetch/src/error_template.rs +++ b/examples/hackernews_js_fetch/src/error_template.rs @@ -15,7 +15,7 @@ pub fn error_template(errors: Option>) -> View { // a unique key for each item as a reference key=|(key, _)| key.clone() // renders each item to a view - view= move |(_, error)| { + children= move |(_, error)| { let error_string = error.to_string(); view! { diff --git a/examples/hackernews_js_fetch/src/routes/stories.rs b/examples/hackernews_js_fetch/src/routes/stories.rs index 700a84ae1..4deaa5a38 100644 --- a/examples/hackernews_js_fetch/src/routes/stories.rs +++ b/examples/hackernews_js_fetch/src/routes/stories.rs @@ -95,12 +95,10 @@ pub fn Stories() -> impl IntoView { - } - } - /> + let:story + > + + }.into_any()) } diff --git a/examples/hackernews_js_fetch/src/routes/story.rs b/examples/hackernews_js_fetch/src/routes/story.rs index daaffa4c9..fa946ba65 100644 --- a/examples/hackernews_js_fetch/src/routes/story.rs +++ b/examples/hackernews_js_fetch/src/routes/story.rs @@ -58,8 +58,10 @@ pub fn Story() -> impl IntoView { } - /> + let:comment + > + + @@ -103,8 +105,10 @@ pub fn Comment(comment: api::Comment) -> impl IntoView { } - /> + let:comment + > + + } })} diff --git a/examples/js-framework-benchmark/src/lib.rs b/examples/js-framework-benchmark/src/lib.rs index c25e246f8..cabc062f4 100644 --- a/examples/js-framework-benchmark/src/lib.rs +++ b/examples/js-framework-benchmark/src/lib.rs @@ -168,7 +168,7 @@ pub fn App() -> impl IntoView { impl IntoView { } - /> + let:todo + > + +