0

Hello i can't figure out how to display a vector of struct.

template rendering:

let a: Vec<ResultsStruct> = serde_json::from_value(query_result).unwrap();   
Template::render("index", json!({ "user": user, "c_api": c_api, "query_result": a }))

template code:

<div class="container">
    {% for i in query_result %}
        {{ i }}
    {% endfor %} 
</div>

i would like to print a struct from the vec like this but i can't figure out how. thank you for the help

i tried to do what it's in the template code up here but nothing works

GranBoh
  • 67
  • 8
  • You'll have to provide at least some info to go by: What do you want the final result to look like? What does the current code produce? If there are any errors, what are the exact error messages? "More/detailed information" == "higher chance we can help you". – Lucas S. Nov 18 '22 at 15:24
  • there's no need of more information, a is Vec and i simply want to display it in the html tera template – GranBoh Nov 18 '22 at 15:30
  • What is `ResultsStruct`? And what should it look like in the rendered HTML? – Jmb Nov 18 '22 at 15:35
  • is a vector with structs inside it. and on html.tera i want to display like {{ ResultsStruct.camp1 }} for every struct that's inside the vec – GranBoh Nov 18 '22 at 15:52

0 Answers0