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
sse-connect="/scrobbles{% if scrobble.is_none() %}?immediate=true{% endif %}"
93
sse-swap="scrobble"
94
>
95
-
{%- match scrobble %} {%- when Some with (ScrobblesTemplate {intro, now_playing, image, srcset}) %}
96
{% include "scrobble.html" %}
97
-
{%- else %}
98
-
{%- endmatch %}
99
</div>
100
</body>
101
</html>
···
92
sse-connect="/scrobbles{% if scrobble.is_none() %}?immediate=true{% endif %}"
93
sse-swap="scrobble"
94
>
95
+
{%- if let Some(ScrobblesTemplate {intro, now_playing, image, srcset}) = scrobble %}
96
{% include "scrobble.html" %}
97
+
{%- endif %}
0
98
</div>
99
</body>
100
</html>
+4
-6
server/templates/scrobble.html
···
1
<div class="bar-container">
2
-
{%- match image %} {%- when Some with (image) %}
3
<img
4
class="bar-cover"
5
src="{{ image }}"
6
alt="Cover art"
7
-
{%- match srcset %} {%- when Some with (srcset) %}
8
srcset="{{ srcset }}"
9
-
{%- else %}
10
-
{%- endmatch %}
11
/>
12
-
{%- else %}
13
-
{%- endmatch %}
14
<p class="bar-text-intro">{{ intro }}</p>
15
<p class="bar-text-music">{{ now_playing }}</p>
16
</div>
···
1
<div class="bar-container">
2
+
{%- if let Some(image) = image %}
3
<img
4
class="bar-cover"
5
src="{{ image }}"
6
alt="Cover art"
7
+
{%- if let Some(srcset) = srcset %}
8
srcset="{{ srcset }}"
9
+
{%- endif %}
0
10
/>
11
+
{%- endif %}
0
12
<p class="bar-text-intro">{{ intro }}</p>
13
<p class="bar-text-music">{{ now_playing }}</p>
14
</div>