Skip to main content

Crate trillium_tera

Crate trillium_tera 

Source
Expand description

§this crate provides the tera templating language for trillium

See the tera site for more information on the tera template language.

use trillium::Conn;
use trillium_tera::{Tera, TeraConnExt, TeraHandler};
use trillium_testing::TestServer;

let mut tera = Tera::default();
tera.add_raw_template("hello.html", "hello {{name}} from {{render_engine}}")?;

let handler = (
    TeraHandler::new(tera),
    |conn: Conn| async move { conn.assign("render_engine", "tera") },
    |conn: Conn| async move { conn.assign("name", "trillium").render("hello.html") },
);

let app = TestServer::new(handler).await;
app.get("/")
    .await
    .assert_ok()
    .assert_body("hello trillium from tera")
    .assert_header("content-type", "text/html");

Structs§

Context
The struct that holds the context of a template rendering.
Tera
Main point of interaction in this library.
TeraHandler
A trillium handler for the Tera template engine

Traits§

Filter
The filter function type definition
Function
The global function type definition
TeraConnExt
Extends trillium::Conn with tera template-rendering functionality.
Test
The tester function type definition