diff options
author | Vika <vika@fireburn.ru> | 2024-09-07 16:47:23 +0300 |
---|---|---|
committer | Vika <vika@fireburn.ru> | 2024-09-07 16:47:23 +0300 |
commit | bd1fb7afd2e0e965989dcfbffc2ff7f4ef828d5d (patch) | |
tree | 342656eaba905e13adc8071ff0376a86a5d23b8d /templates/src | |
parent | c603ece30c6d2df17e0fe42c7b62f29e12df17ac (diff) | |
download | kittybox-bd1fb7afd2e0e965989dcfbffc2ff7f4ef828d5d.tar.zst |
Reduce unwraps in u-ate and u-drank handling
Diffstat (limited to 'templates/src')
-rw-r--r-- | templates/src/mf2.rs | 20 |
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) |