Include askama template

Hello, i'm building a web application with actix and use on top of it askama to for the template.
I want to build my applicatino arround a single tempalte AppInfo that hold all the rest of the template who contains others tempalte ....
In my exemple the struct/template building hold a vec of Property . What i want to do is render building and inside itself it render every properties.
Here is building.html:

<div class="building">
    <div class="building-property">
        <div class="property-title">{{nom}}</div>
        <div class="property-content">{{address}}</div>
        {% for property in properties %}
        {% include "property.html" %}
        {% endfor %}
    </div>
</div>

property.html:

<div class="property">
    <div class="property-title">{{title}}</div>
    <div class="property-content">{{content}}</div>
</div>

And now this is the rust behing it :

#[derive(Serialize, Deserialize, Debug, Clone, Template, Default)]
#[template(path = "building.html")]
pub struct Building {
    properties: Vec<Property>,
    nom: String,
    address: String,
    apartments: Vec<Apartment>,
}

#[derive(Serialize, Deserialize, Debug, Clone, Template, Default)]
#[template(path = "property.html")]
struct Property {
    title: String,
    content: Content,
}

As you can see in my building i loop over every properties and now i want to display them

but I tried to find a find to call the template i found {% include "property.html" %} but i don't know how to pass data.

I need to pass the data and not hard code it because in the rest of the code a lot of struct/template use it and display it. I want to be able to call it from different template.

The final question is: can i call a template from another one while passing data ?

Thanks for every one who will read this :smile:

That sounds like what would typically be called a macro in a templating language.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.