diff --git a/examples/axum_js_ssr/Cargo.toml b/examples/axum_js_ssr/Cargo.toml index 162e2da51b..e386c7077c 100644 --- a/examples/axum_js_ssr/Cargo.toml +++ b/examples/axum_js_ssr/Cargo.toml @@ -27,7 +27,7 @@ tokio = { version = "1.39", features = [ ], optional = true } tower = { version = "0.4.13", optional = true } tower-http = { version = "0.5.2", features = ["fs"], optional = true } -wasm-bindgen = "0.2.92" +wasm-bindgen = "0.2.105" web-sys = { version = "0.3.69", features = [ "AddEventListenerOptions", "Document", diff --git a/examples/axum_js_ssr/src/app.rs b/examples/axum_js_ssr/src/app.rs index b4cbded87e..2019c5a73a 100644 --- a/examples/axum_js_ssr/src/app.rs +++ b/examples/axum_js_ssr/src/app.rs @@ -510,11 +510,9 @@ if (window.hljs) { }); view! {
{code.await}
- { - move || script.get().map(|script| { - view! { } - }) - } + + + } }) }; @@ -567,11 +565,9 @@ if (window.hljs) { }); view! {
{code.await}
- { - move || script.get().map(|script| { - view! { } - }) - } + + + } }) }; diff --git a/examples/hackernews/Cargo.toml b/examples/hackernews/Cargo.toml index 69f9fc9da8..46e18de7c8 100644 --- a/examples/hackernews/Cargo.toml +++ b/examples/hackernews/Cargo.toml @@ -25,7 +25,7 @@ log = "0.4.22" serde = { version = "1.0", features = ["derive"] } gloo-net = { version = "0.6.0", features = ["http"] } reqwest = { version = "0.12.5", features = ["json"] } -wasm-bindgen = "0.2.93" +wasm-bindgen = "0.2.105" web-sys = { version = "0.3.70", features = ["AbortController", "AbortSignal"] } send_wrapper = "0.6.0" @@ -46,12 +46,12 @@ denylist = ["actix-files", "actix-web", "leptos_actix"] skip_feature_sets = [["csr", "ssr"], ["csr", "hydrate"], ["ssr", "hydrate"], []] [package.metadata.leptos] -# The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name +# The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name output-name = "hackernews" # The site root folder is where cargo-leptos generate all output. WARNING: all content of this folder will be erased on a rebuild. Use it in your server setup. site-root = "target/site" # The site-root relative folder where all compiled output (JS, WASM and CSS) is written -# Defaults to pkg +# Defaults to pkg site-pkg-dir = "pkg" # [Optional] The source CSS file. If it ends with .sass or .scss then it will be compiled by dart-sass into CSS. The CSS is optimized by Lightning CSS before being written to //app.css style-file = "./style.css" diff --git a/examples/hackernews/src/routes/stories.rs b/examples/hackernews/src/routes/stories.rs index 3f85d292ee..70fc8f9515 100644 --- a/examples/hackernews/src/routes/stories.rs +++ b/examples/hackernews/src/routes/stories.rs @@ -145,14 +145,11 @@ fn Story(story: api::Story) -> impl IntoView { Either::Left( view! { - {"by "} - {story - .user - .map(|user| { - view! { - {user.clone()} - } - })} {format!(" {} | ", story.time_ago)} + "by " + + {user.clone()} + + {format!(" {} | ", story.time_ago)} impl IntoView {

{story.title}

"(" {story.domain} ")" - {story - .user - .map(|user| { - view! { -

- {story.points} " points | by " - {user.clone()} - {format!(" {}", story.time_ago)} -

- } - })} + +

+ {story.points} " points | by " + {user.clone()} + {format!(" {}", story.time_ago)} +

+

diff --git a/examples/hackernews_axum/Cargo.toml b/examples/hackernews_axum/Cargo.toml index d3343d3561..156137b607 100644 --- a/examples/hackernews_axum/Cargo.toml +++ b/examples/hackernews_axum/Cargo.toml @@ -26,7 +26,7 @@ tower-http = { version = "0.5.2", features = ["fs"], optional = true } tokio = { version = "1.39", features = ["full"], optional = true } http = { version = "1.1", optional = true } web-sys = { version = "0.3.70", features = ["AbortController", "AbortSignal"] } -wasm-bindgen = "0.2.93" +wasm-bindgen = "0.2.105" send_wrapper = { version = "0.6.0", features = ["futures"] } [features] diff --git a/examples/hackernews_axum/src/routes/stories.rs b/examples/hackernews_axum/src/routes/stories.rs index eb2586b3a1..b9bb20f129 100644 --- a/examples/hackernews_axum/src/routes/stories.rs +++ b/examples/hackernews_axum/src/routes/stories.rs @@ -133,7 +133,9 @@ fn Story(story: api::Story) -> impl IntoView { Either::Left(view! { {"by "} - {story.user.map(|user| view ! { {user.clone()}})} + + {user.clone()} + {format!(" {} | ", story.time_ago)} {if story.comments_count.unwrap_or_default() > 0 { diff --git a/examples/hackernews_axum/src/routes/story.rs b/examples/hackernews_axum/src/routes/story.rs index 98544f665b..326b1dc3fe 100644 --- a/examples/hackernews_axum/src/routes/story.rs +++ b/examples/hackernews_axum/src/routes/story.rs @@ -40,18 +40,20 @@ impl LazyRoute for StoryRoute {

- -

{story.title}

-
- - "("{story.domain}")" - - {story.user.map(|user| view! {

- {story.points} - " points | by " - {user.clone()} - {format!(" {}", story.time_ago)} -

})} + +

{story.title}

+
+ + "("{story.domain}")" + + +

+ {story.points} + " points | by " + {user.clone()} + {format!(" {}", story.time_ago)} +

+

diff --git a/examples/hackernews_islands_axum/src/routes/stories.rs b/examples/hackernews_islands_axum/src/routes/stories.rs index 89c09c0932..3111a29aa3 100644 --- a/examples/hackernews_islands_axum/src/routes/stories.rs +++ b/examples/hackernews_islands_axum/src/routes/stories.rs @@ -143,8 +143,10 @@ fn Story(story: api::Story) -> impl IntoView { {if story.story_type != "job" { Either::Left(view! { - {"by "} - {story.user.map(|user| view ! { {user.clone()}})} + "by " + + {user.clone()} + {format!(" {} | ", story.time_ago)} {if story.comments_count.unwrap_or_default() > 0 { diff --git a/examples/hackernews_islands_axum/src/routes/story.rs b/examples/hackernews_islands_axum/src/routes/story.rs index 5ff1a95c0a..c3c2271fc5 100644 --- a/examples/hackernews_islands_axum/src/routes/story.rs +++ b/examples/hackernews_islands_axum/src/routes/story.rs @@ -32,18 +32,20 @@ pub fn Story() -> impl IntoView {

- -

{story.title}

-
- - "("{story.domain}")" - - {story.user.map(|user| view! {

- {story.points} - " points | by " - {user.clone()} - {format!(" {}", story.time_ago)} -

})} + +

{story.title}

+
+ + "("{story.domain}")" + + +

+ {story.points} + " points | by " + {user.clone()} + {format!(" {}", story.time_ago)} +

+

diff --git a/examples/hackernews_js_fetch/src/routes/stories.rs b/examples/hackernews_js_fetch/src/routes/stories.rs index fdbff488e6..13fce10e54 100644 --- a/examples/hackernews_js_fetch/src/routes/stories.rs +++ b/examples/hackernews_js_fetch/src/routes/stories.rs @@ -139,14 +139,11 @@ fn Story(story: api::Story) -> impl IntoView { Either::Left( view! { - {"by "} - {story - .user - .map(|user| { - view! { - {user.clone()} - } - })} {format!(" {} | ", story.time_ago)} + "by " + + {user.clone()} + + {format!(" {} | ", story.time_ago)} impl IntoView {

{story.title}

"("{story.domain}")" - {story - .user - .map(|user| { - view! { -

- {story.points} " points | by " - {user.clone()} - {format!(" {}", story.time_ago)} -

- } - })} + +

+ {story.points} " points | by " + {user.clone()} + {format!(" {}", story.time_ago)} +

+

diff --git a/examples/server_fns_axum/src/app.rs b/examples/server_fns_axum/src/app.rs index cb302f2a14..805a5480ce 100644 --- a/examples/server_fns_axum/src/app.rs +++ b/examples/server_fns_axum/src/app.rs @@ -564,17 +564,12 @@ pub fn FileUploadWithProgress() -> impl IntoView { {move || filename.get().map(|filename| view! {

Uploading {filename}

})} - {move || { - max.get() - .map(|max| { - view! { - - } - }) - }} + + + } } #[component] diff --git a/examples/suspense_tests/src/instrumented.rs b/examples/suspense_tests/src/instrumented.rs index 0178a45e06..e958c1547b 100644 --- a/examples/suspense_tests/src/instrumented.rs +++ b/examples/suspense_tests/src/instrumented.rs @@ -663,26 +663,24 @@ impl From> for FieldNavCtx { #[component] pub fn FieldNavPortlet() -> impl IntoView { let ctx = expect_context::>>(); - move || { - let ctx = ctx.get(); - ctx.map(|ctx| { - view! { -
- "FieldNavPortlet:" - -
- } - }) + + view! { + +
+ "FieldNavPortlet:" + +
+
} } diff --git a/leptos/src/show_let.rs b/leptos/src/show_let.rs index bbaeaa4756..5c0541856b 100644 --- a/leptos/src/show_let.rs +++ b/leptos/src/show_let.rs @@ -160,3 +160,16 @@ where OptionGetter(Arc::new(move || cloned.get())) } } + +/// Marker type for creating an `OptionGetter` from a static value. +/// Used so that the compiler doesn't complain about double implementations of the trait `IntoOptionGetter`. +pub struct StaticMarker; + +impl IntoOptionGetter for Option +where + T: Clone + Send + Sync + 'static, +{ + fn into_option_getter(self) -> OptionGetter { + OptionGetter(Arc::new(move || self.clone())) + } +}