#![allow(unused)] use quasi_declare::declare; use quasi_router::{Choice, Node}; struct Theme { id: String, name: String, selected: bool, } fn chosen_theme(themes: &[Theme]) -> String { themes .iter() .find(|theme| theme.selected) .map(|theme| theme.id.clone()) .unwrap_or_default() } declare! { shape picker(themes: &[Theme]) -> Node; form put "/api/theme" awaiting { submit "Save"; field Select "theme_id" "Theme" { for theme in themes.iter() { option Choice::new(theme.id.clone(), theme.name.clone()) { chosen when theme.selected; } } value chosen_theme(themes); } } } fn main() {}