#rocket #server #web #static #tera

rocket-include-tera

This 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

35 releases

0.5.0 Aug 13, 2021
0.4.21 Mar 11, 2021
0.4.20 Nov 13, 2020
0.4.19 Jul 29, 2020
0.4.3 Jul 26, 2019

#424 in Web programming

Download history 5/week @ 2021-06-02 46/week @ 2021-06-09 7/week @ 2021-06-16 7/week @ 2021-06-23 11/week @ 2021-06-30 8/week @ 2021-07-07 47/week @ 2021-07-14 10/week @ 2021-07-21 87/week @ 2021-07-28 50/week @ 2021-08-04 120/week @ 2021-08-11 5/week @ 2021-08-18 7/week @ 2021-08-25 1/week @ 2021-09-01 4/week @ 2021-09-08 5/week @ 2021-09-15

111 downloads per month
Used in 3 crates

MIT license

30KB
699 lines

Include Tera Templates for Rocket Framework

CI

This 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.

  • 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.
  • 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.
  • 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.
  • tera_resources_initializer! is used for generating a fairing for tera resources.

See examples.

Crates.io

https://crates.io/crates/rocket-include-tera

Documentation

https://docs.rs/rocket-include-tera

License

MIT

Dependencies

~23MB
~505K SLoC