rocket_include_tera/
lib.rs

1/*!
2# Include Tera Templates for Rocket Framework
3
4This is a crate which provides macros `tera_resources_initialize!` and `tera_response!` to statically include Tera files from your Rust project and make them be the HTTP response sources quickly.
5
6* `tera_resources_initialize!` is used in the fairing of `TeraResponseFairing` to include Tera files into your executable binary file. You need to specify each file's name and its path relative to the directory containing the manifest of your package. In order to reduce the compilation time and allow to hot-reload templates, files are compiled into your executable binary file together, only when you are using the **release** profile.
7* `tera_response!` is used for retrieving and rendering the file you input through the macro `tera_resources_initialize!` as a `TeraResponse` instance with rendered HTML. When its `respond_to` method is called, three HTTP headers, **Content-Type**, **Content-Length** and **Etag**, will be automatically added, and the rendered HTML can optionally not be minified.
8* `tera_response_cache!` is used for wrapping a `TeraResponse` and its constructor, and use a **key** to cache its HTML and ETag in memory. The cache is generated only when you are using the **release** profile.
9* `tera_resources_initializer!` is used for generating a fairing for tera resources.
10
11See `examples`.
12*/
13
14#[macro_use]
15extern crate educe;
16
17#[doc(hidden)]
18pub extern crate manifest_dir_macros;
19
20mod functions;
21
22#[cfg(debug_assertions)]
23mod debug;
24
25#[cfg(not(debug_assertions))]
26mod release;
27
28mod macros;
29
30#[cfg(debug_assertions)]
31pub use debug::*;
32#[cfg(not(debug_assertions))]
33pub use release::*;
34pub use rocket_etag_if_none_match::{entity_tag::EntityTag, EtagIfNoneMatch};
35
36const DEFAULT_CACHE_CAPACITY: usize = 64;