#rocket-web #handlebars #rocket #http-response #web #static #web-server

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

65 releases

0.13.7 Dec 15, 2023
0.13.6 Nov 3, 2023
0.13.5 Sep 9, 2023
0.13.4 Nov 3, 2022
0.7.0 Nov 18, 2018

#1236 in Web programming

Download history 6/week @ 2024-09-19 5/week @ 2024-09-26 3/week @ 2024-10-03

353 downloads per month
Used in mprober

MIT license

33KB
718 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

~19–51MB
~875K SLoC