Skip to content

Struggling with multiple data types into template data #562

Answered by dave42w
dave42w asked this question in Q&A
Discussion options

You must be logged in to vote

Apologies, simple when I get my brain in gear. I'm just using a Struct instead of the BTreeMap.

#[derive(Serialize, Deserialize)]
pub struct PlaceContext {
    warnings: String,
    place: Vec<place::Model>,
}

...

let warning_name = "Test Warning".to_string();
let places:Vecplace::Model = Place::find().all(&s.db).await.expect("could not find any places");

let context = PlaceContext {
    warnings: warning_name,
    place: places,
};
s.handlebars.render("place_list.html", &context).unwrap().into() 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dave42w
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant