Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/magiclen/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.
https://github.com/magiclen/rocket-include-handlebars
handlebars rocket template-engine
Last synced: 2 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/magiclen/rocket-include-handlebars
- Owner: magiclen
- License: mit
- Created: 2018-08-16T17:20:04.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T03:01:39.000Z (about 1 year ago)
- Last Synced: 2024-11-14T17:11:57.516Z (3 months ago)
- Topics: handlebars, rocket, template-engine
- Language: Rust
- Size: 111 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Include Handlebars Templates for Rocket Framework
====================[![CI](https://github.com/magiclen/rocket-include-handlebars/actions/workflows/ci.yml/badge.svg)](https://github.com/magiclen/rocket-include-handlebars/actions/workflows/ci.yml)
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](LICENSE)