tangled
alpha
login
or
join now
cherry.computer
/
website
My personal site
cherry.computer
htmx
tailwind
axum
askama
0
fork
atom
overview
issues
pulls
pipelines
refactor: destructure Options in templates with if let
cherry.computer
1 year ago
aa6ca680
75784064
verified
This commit was signed with the committer's
known signature
.
cherry.computer
SSH Key Fingerprint:
SHA256:SIA77Ll0IpMb8Xd3RtaGT+PBIGIePhJJg5W2r6Td7cc=
+6
-9
2 changed files
expand all
collapse all
unified
split
server
templates
index.html
scrobble.html
+2
-3
server/templates/index.html
···
92
92
sse-connect="/scrobbles{% if scrobble.is_none() %}?immediate=true{% endif %}"
93
93
sse-swap="scrobble"
94
94
>
95
95
-
{%- match scrobble %} {%- when Some with (ScrobblesTemplate {intro, now_playing, image, srcset}) %}
95
95
+
{%- if let Some(ScrobblesTemplate {intro, now_playing, image, srcset}) = scrobble %}
96
96
{% include "scrobble.html" %}
97
97
-
{%- else %}
98
98
-
{%- endmatch %}
97
97
+
{%- endif %}
99
98
</div>
100
99
</body>
101
100
</html>
+4
-6
server/templates/scrobble.html
···
1
1
<div class="bar-container">
2
2
-
{%- match image %} {%- when Some with (image) %}
2
2
+
{%- if let Some(image) = image %}
3
3
<img
4
4
class="bar-cover"
5
5
src="{{ image }}"
6
6
alt="Cover art"
7
7
-
{%- match srcset %} {%- when Some with (srcset) %}
7
7
+
{%- if let Some(srcset) = srcset %}
8
8
srcset="{{ srcset }}"
9
9
-
{%- else %}
10
10
-
{%- endmatch %}
9
9
+
{%- endif %}
11
10
/>
12
12
-
{%- else %}
13
13
-
{%- endmatch %}
11
11
+
{%- endif %}
14
12
<p class="bar-text-intro">{{ intro }}</p>
15
13
<p class="bar-text-music">{{ now_playing }}</p>
16
14
</div>