pub fn select_from<K: AsRef<str>, V: AsRef<str>>(
name: impl AsRef<str>,
options: impl IntoIterator<Item = (K, V)>,
selected: Option<&str>,
) -> ElementExpand description
A <select name="…"> holding one <option> per (value, label) pair.
The option whose value equals selected is marked selected; pass None when none is.
§Examples
use molt::prelude::*;
let countries = [("br", "Brasil"), ("ar", "Argentina")];
assert_eq!(
select_from("country", countries, Some("ar")).render(),
concat!(
r#"<select name="country"><option value="br">Brasil</option>"#,
r#"<option value="ar" selected>Argentina</option></select>"#,
)
);