Skip to main content

Crate trillium_askama

Crate trillium_askama 

Source
Expand description

provides support for using the askama compile-time template library with trillium. see https://github.com/djc/askama for more information about using askama.

use trillium::Conn;
use trillium_askama::{AskamaConnExt, Template};
use trillium_testing::TestServer;

#[derive(Template)]
#[template(path = "examples/hello.html")]
struct HelloTemplate<'a> {
    name: &'a str,
}

async fn handler(conn: Conn) -> Conn {
    conn.render(HelloTemplate { name: "trillium" })
}

let app = TestServer::new(handler).await;
app.get("/")
    .await
    .assert_ok()
    .assert_body("Hello, trillium!\n");

Re-exports§

pub use askama;

Traits§

AskamaConnExt
extends trillium conns with the ability to render askama templates
Template
Main Template trait; implementations are generally derived

Derive Macros§

Template
The Template derive macro and its template() attribute.