diff --git a/froxy-templates/examples/friend.rs b/froxy-templates/examples/friend.rs index 5a4edb6..20c06a2 100644 --- a/froxy-templates/examples/friend.rs +++ b/froxy-templates/examples/friend.rs @@ -6,12 +6,12 @@ fn main() { let data = friends::render( &env, friends::FriendsData { - friends: std::iter::from_fn(|| Some(Friend { + friends: std::array::from_fn::<_, 10, _>(|i| Friend { name: "maiboyer".into(), image: "https://friends.42paris.fr/proxy/resize/512/03c61af252becbca11aac5ff49a2e61c/maiboyer.jpg".into(), - position: Some("f1r1s1".into()), - last_active: None, - })).take(10).collect(), + position: (i < 5).then_some("f1r1s1".into()), + last_active: (i > 6).then_some("Last thuesday".into()), + }).to_vec(), }, ) .unwrap(); diff --git a/froxy-templates/src/templates/friends.html b/froxy-templates/src/templates/friends.html index 5a87755..6cefd99 100644 --- a/froxy-templates/src/templates/friends.html +++ b/froxy-templates/src/templates/friends.html @@ -42,7 +42,15 @@
{{ friend.position if friend.position else 'Absent' }} {{ friend.last_active }} + {%- set position = "Absent" -%} + {% if friend.position %} + {%- set position = friend.position -%} + {% endif%} + {%- set last_active = "" -%} + {% if friend.last_active %} + {%- set last_active = friend.last_active -%} + {% endif%} +
{{ position }} {{ last_active }} {% if friend.position %} {% endif %} @@ -50,7 +58,6 @@ {% endfor %} - {% if add %}