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://keats.github.io/tera/) for more information on
15//! the tera template language.
16//!
17//! This crate tracks tera 2, and enables tera's `fast` feature by default. The
18//! `preserve_order` and `unicode` tera features are also available as passthroughs.
19//!
20//! ```
21//! # fn main() -> tera::TeraResult<()> {
22//! use trillium::Conn;
23//! use trillium_tera::{Tera, TeraConnExt, TeraHandler};
24//! use trillium_testing::TestServer;
25//!
26//! let mut tera = Tera::default();
27//! tera.add_raw_template("hello.html", "hello {{name}} from {{render_engine}}")?;
28//!
29//! let handler = (
30//! TeraHandler::new(tera),
31//! |conn: Conn| async move { conn.assign("render_engine", "tera") },
32//! |conn: Conn| async move { conn.assign("name", "trillium").render("hello.html") },
33//! );
34//!
35//! # trillium_testing::block_on(async {
36//! let app = TestServer::new(handler).await;
37//! app.get("/")
38//! .await
39//! .assert_ok()
40//! .assert_body("hello trillium from tera")
41//! .assert_header("content-type", "text/html");
42//! # });
43//! # Ok(()) }
44//! ```
45
46#[cfg(test)]
47#[doc = include_str!("../README.md")]
48mod readme {}
49
50mod tera_handler;
51pub use tera_handler::TeraHandler;
52
53mod tera_conn_ext;
54pub use tera::{Context, Error, Filter, Function, Tera, TeraResult, Test};
55pub use tera_conn_ext::TeraConnExt;