My personal site cherry.computer
htmx tailwind axum askama

fix: work around askama parsing bugs

It doesn't seem to like nesting a block inside a match, so let's use the
older approach of including the block from a separate file for now
instead.

cherry.computer 25047366 e5591f39

verified
+18 -19
+1 -1
server/src/scrobble.rs
··· 40 40 } 41 41 42 42 #[derive(Template, Debug, Clone)] 43 - #[template(path = "index.html", block = "scrobbles")] 43 + #[template(path = "scrobble.html")] 44 44 pub struct ScrobblesTemplate { 45 45 pub intro: &'static str, 46 46 pub now_playing: String,
+1 -18
server/templates/index.html
··· 88 88 </div> 89 89 <div class="scrobble-bar" hx-get="/scrobbles" hx-trigger="every 30s"> 90 90 {% match scrobble %} {% when Some with (ScrobblesTemplate {intro, now_playing, image, srcset}) %} 91 - {% block scrobbles %} 92 - <div class="bar-container"> 93 - {% match image %} {% when Some with (image) %} 94 - <img 95 - class="bar-cover" 96 - src="{{ image }}" 97 - alt="Cover art" 98 - {% match srcset %} {% when Some with (srcset) %} 99 - srcset="{{ srcset }}" 100 - {% else %} 101 - {% endmatch %} 102 - /> 103 - {% else %} 104 - {% endmatch %} 105 - <p class="bar-text-intro">{{ intro }}</p> 106 - <p class="bar-text-music">{{ now_playing }}</p> 107 - </div> 108 - {% endblock scrobbles %} 91 + {% include "scrobble.html" %} 109 92 {% else %} 110 93 {% endmatch %} 111 94 </div>
+16
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>