#rocket #server #web #static #handlebars

rocket-include-handlebars

This is a crate which provides macros handlebars_resources_initialize! and handlebars_response! to statically include HBS (Handlebars) files from your Rust project and make them be the HTTP response sources quickly

59 releases

0.13.0 Aug 13, 2021
0.12.20 Jul 29, 2020
0.12.15 Jun 27, 2020
0.12.11 Mar 14, 2020
0.7.0 Nov 18, 2018

#312 in Web programming

Download history 68/week @ 2021-06-06 8/week @ 2021-06-13 5/week @ 2021-06-20 5/week @ 2021-06-27 8/week @ 2021-07-04 7/week @ 2021-07-11 67/week @ 2021-07-18 69/week @ 2021-07-25 130/week @ 2021-08-01 37/week @ 2021-08-08 72/week @ 2021-08-15 9/week @ 2021-08-22 2/week @ 2021-08-29 10/week @ 2021-09-05 3/week @ 2021-09-12 28/week @ 2021-09-19

149 downloads per month
Used in mprober

MIT license

32KB
742 lines

Include Handlebars Templates for Rocket Framework

CI

This is a crate which provides macros handlebars_resources_initialize! and handlebars_response! to statically include HBS (Handlebars) files from your Rust project and make them be the HTTP response sources quickly.

  • handlebars_resources_initialize! is used in the fairing of HandlebarsResponse to include Handlebars 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.
  • handlebars_response! is used for retrieving and rendering the file you input through the macro handlebars_resources_initialize! as a HandlebarsResponse 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.
  • handlebars_response_cache! is used for wrapping a HandlebarsResponse 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.
  • handlebars_resources_initializer! is used for generating a fairing for handlebars resources.

See examples.

Crates.io

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

Documentation

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

License

MIT

Dependencies

~20MB
~438K SLoC