use timpl::*; fn main() { println!("{}", template()); } pub(crate) fn template() -> String { let profile = profile(); let title = timpl! { Profile of { profile.name } }; let description = timpl! { Profile of { profile.name } writen in Rust by { profile.name } }; timpl! { { title }

{ profile.name }

Wubba lubba dub-dub!

Occupations

{ timpl_map_ln!(profile.occupations.iter(), item, { }) }
Name Status
{ item.name } { item.status.unwrap_or("-") }
} } fn profile() -> Profile<'static> { Profile { name: "Rick Sanchez", occupations: vec![ Occupation { id: 1, name: "Scientist", status: Some("PhD in interdimensional physics"), }, Occupation { id: 2, name: "Inventor", status: None, }, Occupation { id: 3, name: "Resistance fighter", status: Some("Leader of the Rick's Rebellion"), }, Occupation { id: 4, name: "Arms dealer", status: None, }, Occupation { id: 5, name: "Store owner", status: Some("briefly"), }, Occupation { id: 6, name: "Leader of The Council of Ricks", status: Some("formerly"), }, ], } } struct Profile<'a> { name: &'a str, occupations: Vec>, } struct Occupation<'a> { id: u32, name: &'a str, status: Option<&'a str>, }