Skip to main content

view

Attribute Macro view 

Source
#[view]
Expand description

Derives IntoResponse and ViewRender for a struct, linking it to a MiniJinja template.

ยงSyntax

#[view("templates/page.html")]
#[view("templates/page.html", htmx = "templates/partial.html")]

The macro derives serde::Serialize on the struct and implements axum::response::IntoResponse by serializing the struct as the template context and rendering the template. When the optional htmx template path is provided, HTMX requests render the partial instead of the full page.

Requires the templates feature on modo.