about summary refs log tree commit diff
path: root/templates
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2024-09-07 16:47:23 +0300
committerVika <vika@fireburn.ru>2024-09-07 16:47:23 +0300
commitbd1fb7afd2e0e965989dcfbffc2ff7f4ef828d5d (patch)
tree342656eaba905e13adc8071ff0376a86a5d23b8d /templates
parentc603ece30c6d2df17e0fe42c7b62f29e12df17ac (diff)
downloadkittybox-bd1fb7afd2e0e965989dcfbffc2ff7f4ef828d5d.tar.zst
Reduce unwraps in u-ate and u-drank handling
Diffstat (limited to 'templates')
-rw-r--r--templates/src/mf2.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/templates/src/mf2.rs b/templates/src/mf2.rs
index 076989c..550adfc 100644
--- a/templates/src/mf2.rs
+++ b/templates/src/mf2.rs
@@ -237,15 +237,15 @@ markup::define! {
                 }
                 @if post["properties"]["ate"].is_array() || post["properties"]["drank"].is_array() {
                     div {
-                        @if post["properties"]["ate"].is_array() {
+                        @if let Some(ate) = post["properties"]["ate"].as_array() {
                             span { ul {
                                 "Ate:"
-                                @for food in post["properties"]["ate"].as_array().unwrap() {
+                                @for food in ate {
                                     li {
-                                        @if food.is_string() {
+                                        @if let Some(food) = food.as_str() {
                                             // If this is a string, it's a URL.
-                                            a."u-ate"[href=food.as_str().unwrap()] {
-                                                @food.as_str().unwrap().truncate_ellipse(24).as_ref()
+                                            a."u-ate"[href=food] {
+                                                @food.truncate_ellipse(24).as_ref()
                                             }
                                         } else {
                                             // This is a rich food object (mm, sounds tasty! I wanna eat something tasty)
@@ -258,15 +258,15 @@ markup::define! {
                                 }
                             } }
                         }
-                        @if post["properties"]["drank"].is_array() {
+                        @if let Some(drank) = post["properties"]["drank"].as_array() {
                             span { ul {
                                 "Drank:"
-                                @for food in post["properties"]["drank"].as_array().unwrap() {
+                                @for food in drank {
                                     li {
-                                        @if food.is_string() {
+                                        @if let Some(food) = food.as_str() {
                                             // If this is a string, it's a URL.
-                                            a."u-drank"[href=food.as_str().unwrap()] {
-                                                @food.as_str().unwrap().truncate_ellipse(24).as_ref()
+                                            a."u-drank"[href=food] {
+                                                @food.truncate_ellipse(24).as_ref()
                                             }
                                         } else {
                                             // This is a rich food object (mm, sounds tasty! I wanna eat something tasty)