-
Hi, Sorry this is very basic. I have vector of structs (and it is serializable): let places:Vecplace::Model = Place::find().all(&s.db).await That prints as: I add this to a HashMap for Handlebars: This prints: My template is:
At runtime I get: This is my (auto generated) entity struct: I assume that my vector isn't being serialized properly? Or that I need an extra conversion step? I've struggled to find any examples I've tried explicitly converting to json (but wondering if I need to do this for each element in the vector) eg let places:Vecplace::Model = Place::find().all(&s.db).await
The debugging println! s show: My template renders as:
I'm new to rust and all these crates, I also haven't done professional coding for a long time and am trying to get back to it. So I am probably being very slow and stupid. Thanks Dave |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You seem to wrap places in nested vectors, try to fix it like this: let mut data = BTreeMap::new();
// use places directly
data.insert("place".to_string(), places);
println!("data: {:?}", data);
s.templates.render("place_list.html", &data).unwrap().into() And you cannot serialize your data to json to render in handlebars because we only use the json type system not the format. |
Beta Was this translation helpful? Give feedback.
You seem to wrap places in nested vectors, try to fix it like this:
And you cannot serialize your data to json to render in handlebars because we only use the json type system not the format.