Skip to content

Commit 1aaa716

Browse files
authored
examples: use ShowLet where appropriate in examples (#4467)
1 parent 779b2f2 commit 1aaa716

File tree

15 files changed

+107
-111
lines changed

15 files changed

+107
-111
lines changed

examples/axum_js_ssr/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ tokio = { version = "1.39", features = [
2727
], optional = true }
2828
tower = { version = "0.4.13", optional = true }
2929
tower-http = { version = "0.5.2", features = ["fs"], optional = true }
30-
wasm-bindgen = "0.2.92"
30+
wasm-bindgen = "0.2.105"
3131
web-sys = { version = "0.3.69", features = [
3232
"AddEventListenerOptions",
3333
"Document",

examples/axum_js_ssr/src/app.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -510,11 +510,9 @@ if (window.hljs) {
510510
});
511511
view! {
512512
<pre><code class="language-rust">{code.await}</code></pre>
513-
{
514-
move || script.get().map(|script| {
515-
view! { <Script>{script}</Script> }
516-
})
517-
}
513+
<ShowLet some=script let:script>
514+
<Script>{script}</Script>
515+
</ShowLet>
518516
}
519517
})
520518
};
@@ -567,11 +565,9 @@ if (window.hljs) {
567565
});
568566
view! {
569567
<pre><code class="language-rust">{code.await}</code></pre>
570-
{
571-
move || script.get().map(|script| {
572-
view! { <Script>{script}</Script> }
573-
})
574-
}
568+
<ShowLet some=script let:script>
569+
<Script>{script}</Script>
570+
</ShowLet>
575571
}
576572
})
577573
};

examples/hackernews/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ log = "0.4.22"
2525
serde = { version = "1.0", features = ["derive"] }
2626
gloo-net = { version = "0.6.0", features = ["http"] }
2727
reqwest = { version = "0.12.5", features = ["json"] }
28-
wasm-bindgen = "0.2.93"
28+
wasm-bindgen = "0.2.105"
2929
web-sys = { version = "0.3.70", features = ["AbortController", "AbortSignal"] }
3030
send_wrapper = "0.6.0"
3131

@@ -46,12 +46,12 @@ denylist = ["actix-files", "actix-web", "leptos_actix"]
4646
skip_feature_sets = [["csr", "ssr"], ["csr", "hydrate"], ["ssr", "hydrate"], []]
4747

4848
[package.metadata.leptos]
49-
# The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name
49+
# The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name
5050
output-name = "hackernews"
5151
# 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.
5252
site-root = "target/site"
5353
# The site-root relative folder where all compiled output (JS, WASM and CSS) is written
54-
# Defaults to pkg
54+
# Defaults to pkg
5555
site-pkg-dir = "pkg"
5656
# [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 <site-root>/<site-pkg>/app.css
5757
style-file = "./style.css"

examples/hackernews/src/routes/stories.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,11 @@ fn Story(story: api::Story) -> impl IntoView {
145145
Either::Left(
146146
view! {
147147
<span>
148-
{"by "}
149-
{story
150-
.user
151-
.map(|user| {
152-
view! {
153-
<A href=format!("/users/{user}")>{user.clone()}</A>
154-
}
155-
})} {format!(" {} | ", story.time_ago)}
148+
"by "
149+
<ShowLet some=story.user let:user>
150+
<A href=format!("/users/{user}")>{user.clone()}</A>
151+
</ShowLet>
152+
{format!(" {} | ", story.time_ago)}
156153
<A href=format!(
157154
"/stories/{}",
158155
story.id,

examples/hackernews/src/routes/story.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,13 @@ pub fn Story() -> impl IntoView {
3030
<h1>{story.title}</h1>
3131
</a>
3232
<span class="host">"(" {story.domain} ")"</span>
33-
{story
34-
.user
35-
.map(|user| {
36-
view! {
37-
<p class="meta">
38-
{story.points} " points | by "
39-
<A href=format!("/users/{user}")>{user.clone()}</A>
40-
{format!(" {}", story.time_ago)}
41-
</p>
42-
}
43-
})}
33+
<ShowLet some=story.user let:user>
34+
<p class="meta">
35+
{story.points} " points | by "
36+
<A href=format!("/users/{user}")>{user.clone()}</A>
37+
{format!(" {}", story.time_ago)}
38+
</p>
39+
</ShowLet>
4440
</div>
4541
<div class="item-view-comments">
4642
<p class="item-view-comments-header">

examples/hackernews_axum/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ tower-http = { version = "0.5.2", features = ["fs"], optional = true }
2626
tokio = { version = "1.39", features = ["full"], optional = true }
2727
http = { version = "1.1", optional = true }
2828
web-sys = { version = "0.3.70", features = ["AbortController", "AbortSignal"] }
29-
wasm-bindgen = "0.2.93"
29+
wasm-bindgen = "0.2.105"
3030
send_wrapper = { version = "0.6.0", features = ["futures"] }
3131

3232
[features]

examples/hackernews_axum/src/routes/stories.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ fn Story(story: api::Story) -> impl IntoView {
133133
Either::Left(view! {
134134
<span>
135135
{"by "}
136-
{story.user.map(|user| view ! { <A href=format!("/users/{user}")>{user.clone()}</A>})}
136+
<ShowLet some=story.user let:user>
137+
<A href=format!("/users/{user}")>{user.clone()}</A>
138+
</ShowLet>
137139
{format!(" {} | ", story.time_ago)}
138140
<A href=format!("/stories/{}", story.id)>
139141
{if story.comments_count.unwrap_or_default() > 0 {

examples/hackernews_axum/src/routes/story.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,20 @@ impl LazyRoute for StoryRoute {
4040
<Meta name="description" content=story.title.clone()/>
4141
<div class="item-view">
4242
<div class="item-view-header">
43-
<a href=story.url target="_blank">
44-
<h1>{story.title}</h1>
45-
</a>
46-
<span class="host">
47-
"("{story.domain}")"
48-
</span>
49-
{story.user.map(|user| view! { <p class="meta">
50-
{story.points}
51-
" points | by "
52-
<A href=format!("/users/{user}")>{user.clone()}</A>
53-
{format!(" {}", story.time_ago)}
54-
</p>})}
43+
<a href=story.url target="_blank">
44+
<h1>{story.title}</h1>
45+
</a>
46+
<span class="host">
47+
"("{story.domain}")"
48+
</span>
49+
<ShowLet some=story.user let:user>
50+
<p class="meta">
51+
{story.points}
52+
" points | by "
53+
<A href=format!("/users/{user}")>{user.clone()}</A>
54+
{format!(" {}", story.time_ago)}
55+
</p>
56+
</ShowLet>
5557
</div>
5658
<div class="item-view-comments">
5759
<p class="item-view-comments-header">

examples/hackernews_islands_axum/src/routes/stories.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,10 @@ fn Story(story: api::Story) -> impl IntoView {
143143
{if story.story_type != "job" {
144144
Either::Left(view! {
145145
<span>
146-
{"by "}
147-
{story.user.map(|user| view ! { <A href=format!("/users/{user}")>{user.clone()}</A>})}
146+
"by "
147+
<ShowLet some=story.user let:user>
148+
<A href=format!("/users/{user}")>{user.clone()}</A>
149+
</ShowLet>
148150
{format!(" {} | ", story.time_ago)}
149151
<A href=format!("/stories/{}", story.id)>
150152
{if story.comments_count.unwrap_or_default() > 0 {

examples/hackernews_islands_axum/src/routes/story.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,20 @@ pub fn Story() -> impl IntoView {
3232
<Meta name="description" content=story.title.clone()/>
3333
<div class="item-view">
3434
<div class="item-view-header">
35-
<a href=story.url target="_blank">
36-
<h1>{story.title}</h1>
37-
</a>
38-
<span class="host">
39-
"("{story.domain}")"
40-
</span>
41-
{story.user.map(|user| view! { <p class="meta">
42-
{story.points}
43-
" points | by "
44-
<A href=format!("/users/{user}")>{user.clone()}</A>
45-
{format!(" {}", story.time_ago)}
46-
</p>})}
35+
<a href=story.url target="_blank">
36+
<h1>{story.title}</h1>
37+
</a>
38+
<span class="host">
39+
"("{story.domain}")"
40+
</span>
41+
<ShowLet some=story.user let:user>
42+
<p class="meta">
43+
{story.points}
44+
" points | by "
45+
<A href=format!("/users/{user}")>{user.clone()}</A>
46+
{format!(" {}", story.time_ago)}
47+
</p>
48+
</ShowLet>
4749
</div>
4850
<div class="item-view-comments">
4951
<p class="item-view-comments-header">

0 commit comments

Comments
 (0)