Skip to main content

trillium_tera/
lib.rs

1#![forbid(unsafe_code)]
2#![deny(
3    clippy::dbg_macro,
4    missing_copy_implementations,
5    rustdoc::missing_crate_level_docs,
6    missing_debug_implementations,
7    missing_docs,
8    nonstandard_style,
9    unused_qualifications
10)]
11
12//! # this crate provides the tera templating language for trillium
13//!
14//! See [the tera site](https://tera.netlify.app/) for more information on
15//! the tera template language.
16//!
17//! ```
18//! # fn main() -> tera::Result<()> {
19//! use trillium::Conn;
20//! use trillium_tera::{Tera, TeraConnExt, TeraHandler};
21//! use trillium_testing::TestServer;
22//!
23//! let mut tera = Tera::default();
24//! tera.add_raw_template("hello.html", "hello {{name}} from {{render_engine}}")?;
25//!
26//! let handler = (
27//!     TeraHandler::new(tera),
28//!     |conn: Conn| async move { conn.assign("render_engine", "tera") },
29//!     |conn: Conn| async move { conn.assign("name", "trillium").render("hello.html") },
30//! );
31//!
32//! # trillium_testing::block_on(async {
33//! let app = TestServer::new(handler).await;
34//! app.get("/")
35//!     .await
36//!     .assert_ok()
37//!     .assert_body("hello trillium from tera")
38//!     .assert_header("content-type", "text/html");
39//! # });
40//! # Ok(()) }
41//! ```
42
43#[cfg(test)]
44#[doc = include_str!("../README.md")]
45mod readme {}
46
47mod tera_handler;
48pub use tera_handler::TeraHandler;
49
50mod tera_conn_ext;
51pub use tera::{Context, Filter, Function, Tera, Test};
52pub use tera_conn_ext::TeraConnExt;